मान लीजिए हमने Tkinter में Listbox method का उपयोग करके एक listbox बनाया है और हम इस list से multiple selected items remove करना चाहते हैं।
Listbox से multiple list select करने के लिए, हम selectmode को MULTIPLE के रूप में उपयोग करेंगे। अब list पर iterate करके, हम कुछ buttons का उपयोग करके delete operation perform कर सकते हैं।
उदाहरण
# Import the required libraries
from tkinter import *
# Create an instance of tkinter frame or window
win = Tk()
# Set the geometry
win.geometry("700x400")
# Create a text Label
label = Label(win, text="Select items from the list", font=('Poppins bold', 18))
label.pack(pady=20)
# Define the function
def delete_item():
selected_item = my_list.curselection()
for item in selected_item[::-1]:
my_list.delete(item)
my_list = Listbox(win, selectmode=MULTIPLE)
my_list.pack()
items = ['C++', 'java', 'Python', 'Rust', 'Ruby', 'Machine Learning']
# Now iterate over the list
for item in items:
my_list.insert(END, item)
# Create a button to remove the selected items in the list
Button(win, text="Delete", command=delete_item).pack()
# Keep Running the window
win.mainloop()
आउटपुट
उपरोक्त code चलाने से निम्न output produce होगा:

अब, आप listbox में multiple entries select कर सकते हैं और उन entries को list से remove करने के लिए "Delete" button पर क्लिक कर सकते हैं।

Observe, यहां हमने "Delete" button का उपयोग करके list से three entries remove की हैं।