I've built a listbox in Tkinter connected to Sqlite and have different functions with button commands connected to the database which work fine (such as Add, Fetch, Save, etc.) The only control I am having trouble executing is selecting the database entries displaying in my Listbox after I Fetch them from the database. For sake of simplicity, this is my current code just for the Fetch and Load sections:
#Fetch all database records to display in listbox
def fetchRecord():
cont = sqlite3.connect('storagetest.db')
with cont:
cursort = cont.cursor()
list_loadr = cursort.execute('''SELECT name FROM content''')
list_load = list_loadr.fetchall()
for item in list_load:
list.insert(END, item)
cont.commit()
#Load is supposed to select content and insert into Entry field
def loadRecord():
cont = sqlite3.connect('test.db')
c = cont.cursor()
c.execute('SELECT * FROM content')
for item in c:
list.get(list.curselection())
cont.commit()
print ("select")
Basically, I'm having trouble binding the (single) selection in the Listbox and outputting it into an entry box. The shell ouputs no errors, only my print function above outputs. I've been able to find how to do this using a grid layout instead of pack, but without a db connection. However the rest of my gui geometry, buttons and rows are in pack geometry layout. Does anyone know if it's even necessary to have the database connected and executed in this case? I'm pretty lost on this one and haven't seen many resources in regards to using both Sqlite3 and Tkinter out there. Thank you in advance for any help.