[Tkinter-discuss] Persistent Listbox selection

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Mon Mar 9 16:01:35 CET 2015


Dear all,

how can I keep the listbox selection persistent when user selects something in the entry?
In the following example, the rows 0 to 10 are selected in the listbox
If you click and select something in the entry box the selection is lost
Is there an option to avoid this behaviour?

Best Regards
Vasilis

from Tkinter import *
tk = Tk()

listbox = Listbox(tk, selectmode=EXTENDED, exportselection=True)
listbox.pack(fill=BOTH, expand=YES)
for i in range(100): listbox.insert(END,"line %d"%(i))
listbox.selection_set(0,10)

entry = Entry(tk)
entry.pack(side=BOTTOM, fill=X)
entry.insert(0,"Hello world")
tk.mainloop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20150309/eb9d3510/attachment.html>


More information about the Tkinter-discuss mailing list