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.update() self.lb.select_clear(ACTIVE) # needed to un-hilite existing selection self.lb.see(x) self.lb.activate(x) self.lb.select_set(x) 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. Best, On Tue, Feb 13, 2018 at 4:09 PM, Bryan Oakley <[email protected]> wrote: > 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 <[email protected]> > wrote: > >> 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: [email protected] >> WWW: http://www.mellowood.ca >> >> _______________________________________________ >> Tkinter-discuss mailing list >> [email protected] >> https://mail.python.org/mailman/listinfo/tkinter-discuss >> >> > -- **** Listen to my FREE CD at http://www.mellowood.ca/music/cedars **** Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: [email protected] WWW: http://www.mellowood.ca
_______________________________________________ Tkinter-discuss mailing list [email protected] https://mail.python.org/mailman/listinfo/tkinter-discuss
