On Tue, 13 Feb 2018 17:19:44 -0600 Bryan Oakley <bryan.oak...@gmail.com> wrote:
(...) > Another trick would be to get the index of the item at the 0th pixel > location of the widget (eg: the_listbox.index("@0,0"), and another at > the pixel location for the height of the widget (ie: by using the > result of the winfo_height method of the widget). That will tell you > how many visible lines there are. oh, I see now you had that idea first :) So if my snippet is of any use for the OP, the credit goes to you! Best regards Michael > > > On Tue, Feb 13, 2018 at 4:36 PM, Bob van der Poel <b...@mellowood.ca> > wrote: > > > I know how to find the number of items. Just like you show. > > > > No, this is not the size of the box. I have maybe 2000 entries. I can > > set the current selection, etc with code like this: > > > > self.lb.select_clear(ACTIVE) # needed to un-hilite existing > > selection self.lb.activate(x) # make new item > > active self.lb.see(x-10) # force display from 10 > > previous lines > > self.lb.select_set(x) # and select the new item > > > > If the listbox is 20 lines high, this works perfectly. But, if it is a > > different size, it doesn't center. In my case I don't know the size > > of box, so the "-10" is a not-to-intelligent guess. > > > > Thanks. > > > > > > > > On Tue, Feb 13, 2018 at 2:49 PM, Bhaskar Chaudhary > > <bha100...@gmail.com> wrote: > > > >> Hi Bob > >> > >> Are you looking for the number of items in the listbox ? > >> If yes this should give you the number of items. > >> > >> print(len(listbox.get(0, END))) > >> > >> Given that each item occupies one line in the list box, i think it > >> the same as giving the height in lines. > >> > >> regards > >> Bhaskar > >> > >> > >> On 2/13/18, Bob van der Poel <b...@mellowood.ca> 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: b...@mellowood.ca > >> > WWW: http://www.mellowood.ca > >> > > >> > > > > > > > > -- > > > > **** 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 > > Tkinter-discuss@python.org > > https://mail.python.org/mailman/listinfo/tkinter-discuss > > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Humans do claim a great deal for that particular emotion (love). -- Spock, "The Lights of Zetar", stardate 5725.6 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss