[Tkinter-discuss] pack: difference between anchor and side options? (also anchor as a widget option)
Guilherme Polo
ggpolo at gmail.com
Sun Mar 1 00:28:51 CET 2009
On Sat, Feb 28, 2009 at 7:52 PM, John Anon <argo785 at gmail.com> wrote:
> 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/).
>
I wouldn't say the side option has higher precedence than the anchor
option. They work together, when you specify only one of them the
other assumes its default value, when you specify neither of them then
they both assume their default values.
Have fun testing the combinations ;)
> In the meantime, I added a LayoutManagement wiki page (linked to from
> the front page)
Looks a good addition, I have no idea when I will be able to
contribute to it (or even if it will be needed) but I can take a look
at it at least.
> 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
>>
>
--
-- Guilherme H. Polo Goncalves
More information about the Tkinter-discuss
mailing list