Hi! I'm beginner with tkinter, I have one question.
When I select item from the list, I want to copy it and added again to the same list. However, the list is updating with numbers only. Line 4:
2 is added
2 is added
3 is added
I will appreciate any help, Thank you!
When I select item from the list, I want to copy it and added again to the same list. However, the list is updating with numbers only. Line 4:
def add_me():
selected_items = listbox.curselection()
for item in selected_items:
listbox.insert(END, item)
print(item, 'is added')
listbox = Listbox(root, width = 40, height = 15, selectmode = MULTIPLE)
listbox.insert(0, 'Python')
listbox.insert(1, 'C++')
listbox.insert(2, 'C#')
listbox.insert(3, 'PHP')
listbox.pack(pady = 25)
btn = Button(root, text = 'Print', command = print_me).place(x = 200, y = 300)
btn2 = Button(root, text = 'Delete', command = delete_me).place(x = 300, y = 300)
btn3 = Button(root, text = 'Add', command = add_me).place(x = 400, y = 300)Output: 2 is added
2 is added
3 is added
I will appreciate any help, Thank you!
