Newbie here. I am struggling with Tkinter a bit. I have much more complex program but I created this little script to show you what I'm trying to achieve. I have two listboxes, first one contains some items. When I select one item from first listbox, I want certain thing to be inserted into second listbox.
I know that this has to be done via some loop or sth because if you run this script, second listbox has item 4480104160onselect instead of index integer of item in first listbox.
I am having problems to look this up in documentation so if you point me to specific part of it or some tutorial, that will work as well. Thank you very much.
Here is the code:
from Tkinter import *
root = Tk()
parentlist = ['one','two','three']
l1 = Listbox()
for item in parentlist:
l1.insert(END, item)
l1.grid(row=0, column=0)
def onselect(event):
w = event.widget
index = w.curselection()[0]
print "You selected: %d" % int(index)
return int(index)
l1select = l1.bind('<<ListboxSelect>>',onselect)
l2 = Listbox()
l2.insert(END, l1select )
l2.grid(row=0, column=1)
root.mainloop()