Gribouillis, helped me to understand how to invoke a function by btn click event handler, at my last post.Now I am trying to understand how I can handle an selected item event from a list box?
lets say I have a list box like below and I want to call a method to change the frame background color based on which item has been selected
from Tkinter import * class App: def __init__(self, parent): self.myParent = parent self.fm = Frame(parent) self.fm.pack_propagate(0) self.fm.pack() self.Lb1 = Listbox(self.fm,height=4, width=15,selectbackground="orange") self.Lb1.insert(1, "Red") self.Lb1.insert(2, "Green") self.Lb1.insert(3, "Blue") self.Lb1.pack() def make_Red(self): self.fm.configure(bg="RED") def make_Blue(self): self.fm.configure(bg="BLUE") def make_Green(self): self.fm.configure(bg="GREEN") root = Tk() root.title ("Color Option") root.geometry("%dx%d%+d%+d" % (300, 200, 0, 0)) app = App(root) root.mainloop()
can you please take a look at this code and let me know how I can call one of the method by selecting the item from the list?
Edited 5 Years Ago by Behseini: n/a