First try at Tkinter stuff

Randall Hopper aa8vb at yahoo.com
Mon Jan 10 07:20:16 EST 2000


Timothy Grant:
 |I did some more reading last night (Tkinter Life Preserver) and one of
 |the things Matt says is that containers shrink to the size of their
 |contents. Is that always the case, or is there a way around it?

You can always turn off geometry negotiation (see attached).
Also, consider using the "place" manager instead of pack or grid.

Though, I'd really recommend taking a harder look at the pack manager and
using the fill, expand, pad, padx, pady, and anchor options.  For example,
resize the window created by the attached code and notice how badly it
behaves.

Next time you're in the bookstore, browse sections 2.1.1-2.1.7 of
"Effective Tcl/Tk Programming" (Harrison & McLennan).  I find this a useful
Tk reference.

-- 
Randall Hopper
aa8vb at yahoo.com
-------------- next part --------------
#!/usr/bin/env python
#
#  no_resize.py - Show how to disable geometry negoation for a Frame widget.
#

from Tkinter import *

root = Tk()

frame = Frame( root, width=200, height=200, background="blue" )
frame.pack_propagate( 0 )
frame.pack()
            
w = Label( frame, text="Hello, world!", background="yellow" )
w.pack( expand=Y, fill=NONE )

root.mainloop()


More information about the Python-list mailing list