[Tkinter-discuss] pack: difference between anchor and side options? (also anchor as a widget option)

John Anon argo785 at gmail.com
Sat Feb 28 23:52:00 CET 2009


Guilherme,

Sorry for the very late reply, and thank you very much for the information.

So, `side` seems to have precedence over `anchor`. Very good. I'll
experiment with it soon and try to make some time to add my findings
and sample code to [the wiki](http://tkinter.unpythonic.net/wiki/).

In the meantime, I added a LayoutManagement wiki page (linked to from
the front page) along with a small amount of content.




On Tue, Feb 17, 2009 at 10:04 PM, Guilherme Polo <ggpolo at gmail.com> wrote:
> On Fri, Feb 13, 2009 at 7:17 PM, John Anon <argo785 at gmail.com> wrote:
>> What is the difference between `foo.pack(anchor=...)` and `foo.pack(side=...)`?
>>
>
> With "side" you have only four option: top, right, bottom and left,
> with "anchor" you can use some combinations of n, w, s, e or use
> center (the default). You can also use anchor and side at same time,
> for example x.pack(side='top', anchor=''w'). side='top' is the default
> one, it defines where in the master the widget will be packed, anchor
> defines the position of the widget in this side you chose.
>
>> Actually, regarding `anchor`, I see that you can also use it as an
>> option when creating a widget (ex. `Button(parent, anchor=...)` ).
>> What's the difference between using it with pack and using as a widget
>> option?
>
> For using it with pack see the paragraph above.
> Now when you use the option "anchor" while creating a Button, it will
> be defining where its text and/or image will be placed in the widget,
> just like described above. Try creating a Button with some text, pack
> it with expand=True and fill='both' and change the value in anchor to
> see how it behaves.
>
> Anyway, by now (4 days late) you probably already found out all this :)
>
> Regards,
>
> --
> -- Guilherme H. Polo Goncalves
>


More information about the Tkinter-discuss mailing list