This may or may not be the best place to ask this, but here goes:
I'm exploring different GUI packages for python programs I'm writing. I've
played a bit with wx and now am exploring Tkinter and ttk 8.5 following the
tutorial at http://www.tkdocs.com/tutorial.
The first example program is pasted in below:
#!/usr/bin/env python
from Tkinter import *
import ttk
def calculate(*args):
try:
value = float(feet.get())
meters.set((0.3048 * value * 10000.0 + 0.5)/10000.0)
except ValueError:
pass
root = Tk()
root.title("Feet to Meters")
mainframe = ttk.Frame(root, padding="5 5 5 5") # padding order: West, Top,
East, South
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
feet = StringVar()
meters = StringVar()
feet_entry = ttk.Entry(mainframe, textvariable=feet, width=9)
feet_entry.grid(column=2, row=1, sticky=(W, E))
meters_entry = ttk.Entry(mainframe, textvariable=meters, width = 9)
meters_entry.grid(column = 2, row = 2, sticky =(W, E))
ttk.Button(mainframe, text="Calculate", command=calculate, default =
"active").grid(column=3, row=3, sticky=W)
ttk.Label(mainframe, text="feet").grid(column=3, row=1, sticky=W)
ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E)
ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
feet_entry.focus()
root.bind('<Return>', calculate)
root.mainloop()
Quoting from the explanation:
Next, we create a frame widget, which will hold all the content of our user
interface, and place that in our main window.
The"columnconfigure"/"rowconfigure" bits just tell Tk that if the main window
is resized, the frame should expand to take up the extra space.
The problem I'm having is that this doesn't work. If I resize the window, the
light gray background doesn't expand with the root window. I get a light gray
patch the size of the original frame, but it is surrounded by white space. Can
anyone tell me what I'm doing wrong.
64-bit Python 2.7 from python.org and I believe, but can't confirm, that
Tkinter and ttk are from Active State.
Mac OS X 10.8.2, 2 x Quad processor Intel Xeon.
As an additional query, is there another source for Tkinter and ttk?
Thanks in advance,
Bill
_______________________________________________
Pythonmac-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG