I have successfully been able to click a search button on my tkinter GUI and have the results display in my treeview however if I want to search straight again I get an error because when trying to write for the second time it's writing to the same row as the first search query. How would I either clear the treeview or make sure that my program writes to the next row in my treeview?
srchEntry = str(searchEntry.get())
conn = sqlite3.connect('test.db')
c = conn.cursor()
c.execute("SELECT memberID, fullName, username FROM Test WHERE fullName ='"+srchEntry+"'")
conn.commit()
data = c.fetchall()
treeview.insert("", 0, 1, values=(str(data[0][0]), str(data[0][1]), str(data[0][2])))
So 'data' will return ('memberID', 'fullname', 'username') and I am inserting those values into my treeview
Read doc Treeview.insert.
insert()
has parameter index
to choose row. Or you can use word end
to put after last row.
delete()
needs id
of inserted row/item (not row number)
item_id = treeview.insert(...)
and later
treeeview.delete(item_id)