Problem resizing a window and button placement

Grant Edwards grant.b.edwards at gmail.com
Fri Feb 23 22:28:27 EST 2024


On 2024-02-24, MRAB via Python-list <python-list at python.org> wrote:
> On 2024-02-24 01:14, Steve GS via Python-list wrote:
>
>> Python, Tkinter: How do I determine if a window has been resized? I
>> want to locate buttons vertically along the right border and need
>> to know the new width. The buttons are to move with the change of
>> location of the right-side border.
>
> Bind an event handler for '<Configure>':
>
> ----8<----
> [...]
> ----8<----
>
> Are you placing the buttons yourself? I always use layouts and they 
> handle such things automatically.

Yes, definitely what he said: use a layout manager.

I hope this doesn't sound rude, but if you're calculating button
positions based on window size, you're doing it wrong and will end up
wasting a lot of time to produce something that won't work right.

Use a layout manager:

  https://tkinterpython.top/layout/#:~:text=Tkinter%20has%20three%20built%2Din,%2C%20grid%20%2C%20and%20place%20managers.

  https://www.pythonguis.com/tutorials/create-ui-with-tkinter-pack-layout-manager/

  https://www.pythonguis.com/tutorials/use-tkinter-to-design-gui-layout/

You'll have to spend a little time learning how they work, but in the
end you'll get done sooner and have better results.

--
Grant



More information about the Python-list mailing list