[Tkinter-discuss] Confused by frames
Chris Niekel
chris at niekel.net
Sat Jan 13 22:27:37 CET 2007
Hi,
I'm trying to combine a couple of widgets into a frame as a reusable
component. Somehow though, things change when I put some part in a class,
derived from Frame.
Version 1:
class F1(Frame):
def __init__(self, *args, **kw):
Frame.__init__(self, *args, **kw)
Label(text="F1").grid(row=5,column=5)
r = Tk()
b = Button(r, text='button').grid(row=0,column=1)
f = F1(r).grid(row=0,column=0)
r.mainloop()
Version 2:
from Tkinter import *
r = Tk()
b = Button(r, text='button').grid(row=0,column=1)
f1 = Frame(r)
f1.grid(row=0,column=0)
Label(f1, text='F1').grid(row=5,column=5)
r.mainloop()
I would think these are equivalent, but they're not. Version 2 has the
behaviour I expect (a new frame, so the label is on the left).
Did I do something wrong in version 1, or is there another way to make a
class with the label which behaves like a frame?
Regards,
Chris
More information about the Tkinter-discuss
mailing list