Python Forum
[Tkinter] Database with gui
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Database with gui
#3
(Mar-20-2021, 02:23 PM)deanhystad Wrote: Searching works fine as far as I can tell. What do you think is wrong?

You get the index error when doing this:
index = list.curselection()[0]
And there is nothing selected in the Listbox. Since this is something that can legitimately happen, you need to protect against it.
def get_selected_row(event):
    global selected_row
    index = list.curselection()
    if not index:
        return
    selected_row = list.get(index[0])
    ...
By the way, list is a built-in Python function and should not be used as a variable name.

If I add:
if not index:
    return
The error persist.
If I use:
selected_row = list.get(index[0])
after that, it shows me this error: 'int' object is not subscriptable

About the search function: what if I want to search on just an entered field or matching the only fields filled? So if user types one, two or more fields, they must all match, even if some fields are not filled. I tried with AND in the query, but the result is not what I expected.
Reply


Messages In This Thread
Database with gui - by mark9 - Mar-19-2021, 08:26 PM
RE: Database with gui - by deanhystad - Mar-20-2021, 02:23 PM
RE: Database with gui - by mark9 - Mar-20-2021, 04:32 PM
RE: Database with gui - by deanhystad - Mar-20-2021, 05:23 PM
RE: Database with gui - by mark9 - Mar-21-2021, 09:33 AM
RE: Database with gui - by deanhystad - Mar-22-2021, 02:55 AM
RE: Database with gui - by mark9 - Mar-22-2021, 12:03 PM
RE: Database with gui - by deanhystad - Mar-21-2021, 09:30 PM
RE: Database with gui - by deanhystad - Mar-22-2021, 02:44 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020