Python Tkinter将队列元素表示为标签

我有一个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,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,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   |
+---------+-----------+--------+-------------+------------+----------+-------+------------+
hanihani8928 回答:Python Tkinter将队列元素表示为标签

看看https://stackoverflow.com/help/minimal-reproducible-example,这-它使用import { async,ComponentFixture,TestBed } from '@angular/core/testing'; import { BankDetailsComponent } from './bank-details.component'; describe('BankDetailsComponent',() => { let component: BankDetailsComponent; let fixture: ComponentFixture<BankDetailsComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ BankDetailsComponent ],imports: [...],providers: [...] }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(BankDetailsComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should get receiver currency Xpath',() => { ... }); }); 来跟踪标签:

list
本文链接:https://www.f2er.com/3167353.html

大家都在问