Tkinter pack bug in Python 2.3
Frank Stajano
fms27 at cam.ac.uk
Sun Nov 2 07:30:41 EST 2003
The compact form of pack behaves differently (and I believe incorrectly)
compared to the long form. The following two scripts demonstrate it, at
least on this interpreter:
Python 2.3.2 (#1, Oct 9 2003, 12:03:29)
[GCC 3.3.1 (cygming special)] on cygwin
# First script, no bug
# I want a canvas inside a frame inside a toplevel, with the canvas
# filling the toplevel even as I resize the window. This does it.
from Tkinter import *
root = Tk()
frame = Frame(root, bg="lightBlue")
frame.pack(side=TOP, expand=1, fill=BOTH)
canvas = Canvas(frame, bg="lightGreen")
canvas.pack(side=TOP, expand=1, fill=BOTH)
mainloop()
# Second script, bug
# I want a canvas inside a frame inside a toplevel, with the canvas
# filling the toplevel even as I resize the window. This doesn't do
# it, and instead makes the canvas a sibling of the frame, instead of
# a child. (Try resizing the toplevel and you'll see.) Why?
from Tkinter import *
root = Tk()
frame = Frame(root, bg="lightBlue").pack(side=TOP, expand=1, fill=BOTH)
canvas = Canvas(frame, bg="lightGreen").pack(side=TOP, expand=1, fill=BOTH)
mainloop()
Frank (filologo disneyano) http://www-lce.eng.cam.ac.uk/~fms27/
More information about the Python-list
mailing list