[Python] Tkinter Listbox How to tell if an item is selected

Discussão em 'Python' iniciado por Stack, Janeiro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to create a simple GUI that allows the user to press a button, which will delete an entry from a shown Listbox. However, the console throws an error if no entry is selected, so how would I determine if the user has selected an entry. Here's my code:

    selection = self.recipe_list.curselection()
    if not selection is None:
    self.recipe_list.delete(selection)
    else:
    print("Nothing to delete!")

    Continue reading...

Compartilhe esta Página