I have a school project (We’re allowed help from any source, not cheating) to create a GUI using tkinter and read in a .db file to print the results in the GUI. The .db file is a list of game details. I have completed the code to read the .db file and the code for the GUI. We’re supposed to be able to sort and search the data but i can’t even get this part finished in ordre to start that. However, for the final part when I have to print the list in the GUI, only the final result in the list is being displayed. The program has to be finished for 1 week today (26 January 2021) and I just need help with this final part. This is my first time using tkinter so I am aware the GUI is very simple !
I just need all the results from the list to be printed instead of just the last result.
I’ll attach my code below:
indent preformatted text by 4 spaces
import sqlite3
from tkinter import *
from tkinter import messagebox
def setupConnection():
global db
db = sqlite3.connect(‘gamesArchive.db’)
global c
c = db.cursor()
global tableName
tableName = 'games'
def getAllGames(db):
c.execute(’’‘SELECT * FROM games’’’)
data =
for row in c.fetchall():
data.append(row)
return data
window = Tk()
window.title(“Welcome to Zach’s Game Archive!”)
window.configure(background=‘blue’)
lbl = Label(window, text=“Click the box to view the game archives”, font=(“Arial Bold”, 25))
lbl.grid(column=0, row=0)
window.geometry(‘5000x3000’)
def clicked():
setupConnection()
gamesData = getAllGames(db)
for game in gamesData:
lbl.configure(text= game, font=(“Arial Bold”, 8))
btn = Button(window, text=“Click Me”, command=clicked, bg=“orange”, fg=“red”, height = 10, width = 20)
btn.grid(column=1000, row=1000)
window.mainloop()