Re: Persistent Listbox selection

Michael Lange <[email protected]>
Newsgroups gmane.comp.python.tkinter
Message-ID <[email protected]>
Hi Vasilis,

try exportselection=False

Regards

Michael

On Mon, 9 Mar 2015 15:01:35 +0000
Vasilis Vlachoudis <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.