Getting the text from a Listbox item
If you want to get every item of the Listbox then you can use this. Keep in mind that what is returned is a tuple
.get(0, tk.END)
If you want the item(s) from the current selection then you can use this. Keep in mind that what is returned is a tuple
.curselection()
However, this only gives you the indexes of the selected items. To get the text simply use something like this. Using the index values from .curselection()
to get the items from the entire selection
import tkinter as tkl_box = tk.Listbox(...)all_items = l_box.get(0, tk.END) # tuple with text of all items in Listboxsel_idx = l_box.curselection() # tuple with indexes of selected itemssel_list = [all_items[item] for item in sel_idx] # list with text of all selected items