[Tkinter-discuss] Persistent Listbox selection

Michael Lange klappnase at web.de
Mon Mar 9 19:14:40 CET 2015


Hi Vasilis,

try exportselection=False

Regards

Michael

On Mon, 9 Mar 2015 15:01:35 +0000
Vasilis Vlachoudis <Vasilis.Vlachoudis at cern.ch> wrote:

> 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()



.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

You speak of courage.  Obviously you do not know the difference between
courage and foolhardiness.  Always it is the brave ones who die, the
soldiers.
		-- Kor, the Klingon Commander, "Errand of Mercy",
		   stardate 3201.7


More information about the Tkinter-discuss mailing list