amcleod |
07-16-2012 10:05 PM |
Unexpected behaviour with Python / Tkinter
New to Python & Tkinter, so need some help.
When you do
Code:
Label( framename, ...)
Isn't the label supposed to appear inside the named frame? I'm running the following script:
Code:
#!/usr/bin/python
from Tkinter import *
# create toplevel container widget
root = Tk()
root.config( bg='blue' )
# create separate container frames for header line and three data lines
hdr = Frame( root, height=16, bg='yellow').pack(side=TOP, fill=X)
ln1 = Frame( root, height=16, bg='green').pack(side=TOP, fill=X)
ln2 = Frame( root, height=16, bg='pink').pack(side=TOP, fill=X)
ln3 = Frame( root, height=16, bg='orange').pack(side=TOP, fill=X)
d0 = Label( hdr, bg='cyan', width=10, text='DATE' ).pack( side=LEFT )
d1 = Label( ln1, bg='gray', width=10, text='2007-06-13' ).pack( side=LEFT )
d2 = Label( ln2, bg='cyan', width=10, text='2012-04-09' ).pack( side=LEFT )
d3 = Label( ln3, bg='gray', width=10, text='1997-11-27' ).pack( side=LEFT )
t0 = Label( hdr, bg='magenta', width=6, text='TIME' ).pack( side=LEFT )
t1 = Label( ln1, bg='purple', width=6, text='12:45' ).pack( side=LEFT )
t2 = Label( ln2, bg='magenta', width=6, text='13:25' ).pack( side=LEFT )
t3 = Label( ln3, bg='purple', width=6, text='11:06' ).pack( side=LEFT )
root.mainloop()
Labels aren't appearing inside container frames as I expect, but are inside the root frame after the container frames. Am I mistaken in thinking that a label should appear inside it's parent? If so, how do I get a label to appear inside a particular frame of choice? (Weird set of colours solely so I can see what ends up where.)
|