Getting closer :)
I asked the question wrongly. I need to determine the number of VISIBLE
lines in the listbox.
Using the .winfo_height() does return the height in pixels. Note: You do
have to make the widget visible before doing this, otherwise you just get
"1" returned. widget.update() works for this.
So, the next question is: what is the line size?
Now, to make life much simpler :) I just played a bit and discovered that
if I make the listbox visible BEFORE the selection, it automatically
centers. So, my code now becomes:
self.lb.select_clear(ACTIVE) # needed to un-hilite existing selection
Easy. And I don't need to worry about the size of the box!
Well, mostly. If the selection I want is already on the screen, then the
box doesn't scroll to center. I think I can live with that.
On Tue, Feb 13, 2018 at 4:09 PM, Bryan Oakley <bryan.oak...@gmail.com>
> The actual height of any widget can be obtained with the winfo_height
> method. It returns the value in pixels. To get the height in number of
> lines you'll have to compute the height of your font and do a little math.
> On Tue, Feb 13, 2018 at 12:11 PM, Bob van der Poel <b...@mellowood.ca>
>> Is there a way to get the current height (hopefully in lines) of a
>> listbox? I'd like to center, vertically, the result of a search.
>> **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars ****
>> Bob van der Poel ** Wynndel, British Columbia, CANADA **
>> EMAIL: b...@mellowood.ca
>> WWW: http://www.mellowood.ca
>> Tkinter-discuss mailing list
**** Listen to my FREE CD at http://www.mellowood.ca/music/cedars ****
Bob van der Poel ** Wynndel, British Columbia, CANADA **
Tkinter-discuss mailing list