I have to check in an if statement if my Listbox() has one of its elemets selected or not.
Obviously, when I check it and its actually empty, it raises the error _tkinter.TclError: PRIMARY selection doesn't exist or form "STRING" not defined.
Is there a way (without exception handling) to check this out? Because I really need it to be a if stament.
My code is the following:
listboxTime = Listbox(...)
...
elif listboxTime.curselection() :
tkinter.messagebox.showwarning("Error", "Error text")
...
The last thing I tried was with curselection() but it raises and index exception, because the list is empty. Any ideas? Thank you.
Aucun commentaire:
Enregistrer un commentaire