Tkinter Help

Chad Netzer cnetzer at mail.arc.nasa.gov
Mon May 5 17:39:12 EDT 2003


On Mon, 2003-05-05 at 13:50, Brian R. Szmyd wrote:
> ahh, that does help with the horizontal problem...but i was really more 
> concerned with if i later clear the items in that frame and add new 
> ones, the vertical size changes.  This has been a simple solution in 
> other GUI libraries by just specifing the toplayer window size and 
> making "resizable" false...

The methods are 'pack_propagate()' or 'grid_propagate()', depending on
whether you will packing widgets in the frame or gridding.  Since your
example uses gridding, here it is using grid_propagate( 0 ).  That
essentially tells the frame to not resize itself to the smallest
possible size to fit the gridded slaves within it.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from Tkinter import *

root = Tk()

frame = Frame(root, width=640, height=480, bg='White')
frame.pack(expand=1, fill=BOTH)
frame.grid_propagate( 0 )

label = Label(frame, text='Some Text')
label.grid(row=0, column=0)

root.mainloop()

-- 

Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)






More information about the Python-list mailing list