class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.create_widgets()
def create_widgets(self):
self.search_var = StringVar()
self.search_var.trace("w", lambda name, index, mode: self.update_list())
self.entry = Entry(self, textvariable=self.search_var, width=13)
self.lbox = Listbox(self, width=50, height=30, selectmode=EXTENDED)
self.rbox = Listbox(self, width=50, height=30)
self.btnGet = Button(self, text="Add to Selection", command=self.get_selection())
self.entry.grid(row=0, column=0, padx=10, pady=3)
self.lbox.grid(row=1, column=0, padx=10, pady=3)
self.rbox.grid(row=1, column=1, padx=10, pady=3)
self.btnGet.grid(row=2, column=0, padx=10, pady=3)
self.update_list()
def get_selection(self):
print("Get Selection")
items = [self.lbox_list[int(item)] for item in self.lbox.curselection()]
print(items)
def main():
root = Tk()
root.title('Filter Listbox Test')
app = Application(master=root)
print('Starting mainloop()')
root.mainloop()
main()
My code reads from an XML file and populates a listbox. I want a button to copy my selection from lbox to rbox. However my button doesn't seem to fire and I am not sure why.