[Tutor] Tkinter question

Jose Amoreira amoreira@mercury.ubi.pt
Tue, 09 Jan 2001 15:34:50 +0000

I'm not able to get information on the size of a widget using its cget
method. For instance:

>>> r=Frame(None,height=300)
>>> r.pack()
>>> r=Frame(None,height=300,width=100)
>>> r.pack()
>>> r.cget('height')
>>> r.cget('width')

So far, so good. But if we now resize the frame widget via the window
manager, by dragging its border with the mouse, the changes are not
updated in the widget's attributes (even if we call r.update()), and
further querries with cget don't show the modifications. How can we get
the value of these attributes?

To be more specific, what I'd really need is a method to determine the
number of visible lines in an expandable tkinter listbox, to handle
<page-down/up> keyboard events. I managed to get the height of the
listbox in pixels using winfo methods, but the relation of this number
to the number of visible lines depends on the font used, and probably on
the border size, etc.

Thanks for any help!