Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17331

How to remove multiple selected items in listbox in tkinter Python?

$
0
0

I want to be able to delete all selected items when I use selectmode=MULTIPLE.I have tried to delete but it only deletes the item that was selected last. Is there any way to delete all of the items.

Thanks

from tkinter import *def abc():    listbox.delete(ACTIVE)def xyz():    z=listbox.get(0, END)    print (z)master = Tk()scrollbar = Scrollbar(master,orient=VERTICAL)listbox = Listbox(master, yscrollcommand=scrollbar.set, selectmode=MULTIPLE)scrollbar.config(command=listbox.yview)b = Button(master, text="delete", command=abc)b.pack(side=RIGHT)b2 = Button(master, text="save", command=xyz)b2.pack(side=RIGHT)scrollbar.pack(side= RIGHT, fill=Y)listbox.pack(side=LEFT)for item in ["one", "two", "three", "four", "five"]:    listbox.insert(END, item)mainloop()

Viewing all articles
Browse latest Browse all 17331

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>