Mailing List Archive

1 2  View All
Re: RE: Problem resizing a window and button placement [ In reply to ]
On 27/02/2024 07:13, Steve GS via Python-list wrote:

> Aside from using it to resized
> the window, is there no way to
> know the last value of the
> change for use in the program?

The last value would be the current width.
And you know how to get that as shown in
your configure function:

Ww = root.winfo_width()

> I could write the value to a
> label and read it back later

That's no different to writing it to
global Ww and accessing that as demonstrated
in my last code post (with button).

>>> It's better just to ask tk
> for the values whenever you
> need them, as you do inside
> your handler.
>
> How would that be done?

Ww = root.winfo_width()

Provided you can access the root widget
(which is (nearly?) always true) you
can get the width of the main window.

But can I ask if you have a particular use-case
in mind for this? We started out talking about
relocating some widgets when the window was
resized. We established that the best place
to do that was inside the configure event
handler, with no need to store the width.
(assuming you aren't using a dynamic layout
manager(grid/pack/form) which would be better
still!)

We've now moved on to the more general issue
of communicating values between event handlers
(although still using the width as our exemplar).
Is this just academic interest or do you have
a specific need for this? If we know the need
we might be able to suggest a specific (and
possibly better?)solution.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


--
https://mail.python.org/mailman/listinfo/python-list

1 2  View All