我有一个Tkinter应用程序,它不能基于我的队列值生成标签。每个标签都包含产品详细信息。每个队列元素都是从客户订单的数据库表中获取的。但是,我需要一个按钮来按complete,它会弹出队列项,并从窗口中删除标签。我几乎得到了它的工作,按钮与第一个标签工程,并没有删除标签后,这个
我还没有包括最小方法的队列代码
conn=sqlite3.connect("system.db")
cur=conn.cursor()
query = cur.execute("""SELECT orderid, product, size, quantity, milkOptions FROM
activeCustomerOrders""").fetchall()
conn.commit()
conn.close()
customerQueue = Queue()
for row in query:
customerQueue.enqueue(row)
class MyFirstGUI:
def __init__(self, master):
self.master = master
master.title("A simple GUI")
self.label = Label(master, text="This is our first GUI!")
self.label.pack()
self.completedButton = Button(master,text="Complete",width=30,height=5,bg="green")
self.completedButton.pack(side=BOTTOM)
self.completedButton.bind('<Button-1>',
self.orderFulfilled)
for item in customerQueue.queue:
self.button = Label(master,text=item,width=30,height=5,bg="red")
self.button.pack(side=LEFT)
def orderFulfilled(self, event):
#print("hi")
customerQueue.dequeue()
for item in customerQueue.queue:
self.button.pack_forget()
#self.button =
Label(self.master,text=item,width=30,height=5,bg="red")
root = Tk()
my_gui = MyFirstGUI(root)
root.mainloop()
+---------+-----------+--------+-------------+------------+----------+-------+------------+
| orderid | product | size | milkOptions | orderDate | quantity | price | customerid |
+---------+-----------+--------+-------------+------------+----------+-------+------------+
| 1 | Espresso | Small | Soya | 2019-10-29 | 1 | 1.0 | 1 |
| 2 | Cappucino | Small | SemiSkimmed | 2019-10-29 | 1 | 1.0 | 1 |
| 3 | Cappucino | Small | SemiSkimmed | 2019-10-29 | 1 | 1.0 | 1 |
| 4 | Cappucino | Medium | SemiSkimmed | 2019-10-29 | 1 | 1.0 | 1 |
+---------+-----------+--------+-------------+------------+----------+-------+------------+
看看https://stackoverflow.com/help/minimal-reproducible-example,它使用
list
跟踪标签:相关问题 更多 >
编程相关推荐