I am making a python app with a Tkinter GUI. So far it has some dynamically created listboxes which I will link all to one scrollbar. I need a way to let yscroll()
know which listbox has been scrolled. Passing the i
variable to yscroll()
does not work.
from Tkinter import *
class MyApp(Tk):
def __init__(self):
Tk.__init__(self)
self.title(' - My App - ')
self.listboxes = []
for i in xrange(5):
lb = Listbox(self, yscrollcommand=lambda i, *args: self.yscroll(i, *args))
for x in xrange(30):
lb.insert('end', x)
lb.pack(fill='y', side='left')
self.listboxes.append( lb )
self.scrollbar = Scrollbar(self, orient='vertical')
self.scrollbar.pack(side='right', fill='y')
def yscroll(self, i, *args):
print i
print args
ma = MyApp()
ma.mainloop()