Why Isn't The Natural Height Of A Frame Updated Immediately?
I am writing a widget to display some lines of text (via a Label in a Frame) and will need to adjust the font size once the text height is larger than the height of the containing
Solution 1:
Until event handler returns, changes made there are not updated.
But you can force update using update_idletasks
:
self.l.configure(text=message, font=('Arial', 30))
self.l.update_idletasks()
UPDATE
winfo_height()
documentation also mentions update_idletasks
:
Get the height of this widget, in pixels. Note that if the window isn’t managed by a geometry manager, this method returns 1. To you get the real value, you may have to call
update_idletasks
first. You can also usewinfo_reqheight
to get the widget’s requested height (that is, the “natural” size as defined by the widget itself based on it’s contents).
Post a Comment for "Why Isn't The Natural Height Of A Frame Updated Immediately?"