I am having a strange problem using a tkinter listbox. My GUI also has an entry field, and when the value in the entry field is selected by click and drag the listbox selections are deselected. The below code recreates the issue in entirety. I run python 2.7 on windows.
import Tkinter as Tkinter
class window(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.grid()
self.columnconfigure(0, minsize=200)
self.LB = Tkinter.Listbox(self, bg='white',height=3, selectbackground='blue',relief='groove',selectmode='multiple')
self.LB.grid(row=0, column=0, sticky='NSEW')
self.LB.insert(1, '1')
self.LB.insert(2, '2')
self.LB.insert(3, '3')
self.LB.selection_set(0)
self.LB.selection_set(2)
self.E_var = Tkinter.StringVar()
self.E = Tkinter.Entry(self, textvariable=self.E_var)
self.E.grid(column=0, row=1, sticky='NSEW')
self.E_var.set("'Click and drag' select me!")
if __name__ == "__main__":
app = window(None)
app.title('Window')
app.mainloop()