Tkinter pack method question

Steven Taschuk staschuk at telusplanet.net
Fri Feb 14 15:54:19 EST 2003


Quoth Manuel Lanctot:
> Jonas Geiregat wrote:
> 
> > using Tkinter when using the pack method how can you set side to LEFT and
> > TOP ? like
> > instance.pack(side=TOP and side=LEFT)
> > how do you code this right
> 
> If I remember correctly, pack() uses N, SW, E, etc. to "anchor" widgets. So 
> you could use to get TOP and LEFT:
> instance.pack(anchor=NW)

This is so, though it is important to note that there is a
difference between
	widget.pack(side=TOP, anchor=NW)
and
	widget.pack(side=LEFT, anchor=NW)
since the pack geometry manager gives each widget a rectangular
parcel which goes from one edge of the available space to the
other edge.  In other words, you can't get the packer to do
	+--------+------------+
	|        |            |
	| widget |            |
	|        |            |
	+--------+            |
	|                     |
	|    unused space     |
	|                     |
	+---------------------+
and expect subsequently packed widgets to fill up the L-shaped
region.  You can only get either
	+--------+----------------+
	|        |                |
	| widget |   never used   |
	|        |                |
	+--------+----------------+    with side=TOP, anchor=NW
	|                         |
	| space for other widgets |
	|                         |
	+-------------------------+
or
	+--------+------------+
	|        |            |
	| widget |   space    |
	|        |    for     |
	+--------+   other    |        with side=LEFT, anchor=NW
	|        |   widgets  |
	| never  |            |
	|  used  |            |
	|        |            |
	+--------+------------+

-- 
Steven Taschuk           |   7\ 7'Z {&~         .     St. George
staschuk at telusplanet.net |     Y r          --/hG-      &  the
                         | (__/ )_             1^1`     Dragon





More information about the Python-list mailing list