I am building a restaurant menu using tkinter, python and sql tables, and I want the label widget "list" to display the menu items. So far, I have these functions (not the whole program):
`list = tk.Label(text = '',bg = 'black',font = ('Baskerville', 20))
list.grid(column = 0,row = 2, columnspan = 4,sticky = 'W')
#Setup - Python
descEntree = {
1:"Flour tortilla triangles filled with shredded cheddar, monterey jack, chicken, salsa and pico de gallo",
2:"Mini sandwiches with salmon, cream cheese, chives and gouda"
}
descMain = {}
descDessert = {}
def getItem(ID, course):
currentItem = ''
table_name = "Menu" + course
query = "SELECT Item FROM {} WHERE ID = %s".format(table_name)
cur.execute(query, (ID,))
result = cur.fetchone()
currentItem = result[0]
return currentItem
def printItems(course):
cur.execute("select max(ID) from {}".format("Menu" + course))
n = cur.fetchone()
for i in range(1,n[0] + 1):
list.config(text = '\n' + getItem(i,'Entree') + '\n' + descEntree[i])
printItems('Entree')
w.mainloop()`
However it only prints the last item and desc in the table: