[Tkinter-discuss] Listbox size
Michael Lange
klappnase at web.de
Tue Feb 13 19:05:04 EST 2018
On Wed, 14 Feb 2018 00:32:09 +0100
Michael Lange <klappnase at web.de> wrote:
(...)
> I guess
> this simple function is certainly not perfect (but maybe it is already
> good enough):
um, maybe that test() function should be slightly changed, like this
(although yview() does not seem to complain about negative indices):
def test(event):
i = 597
wd = event.widget
wd.selection_clear(0, 'end')
wd.selection_set(i)
wd.update_idletasks()
h1 = wd.winfo_height()
i1, i2 = wd.nearest(0), wd.nearest(h1)
index = i - (i2-i1)/2
if index < 0:
index = 0
wd.yview(index)
Best regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
It is necessary to have purpose.
-- Alice #1, "I, Mudd", stardate 4513.3
More information about the Tkinter-discuss
mailing list