我创建了一个包含按钮的简单应用程序,因此当单击该按钮时,它会将按钮名称和点击次数保存到Text
但我的问题是,当我点击另一个按钮时iT通过删除旧的一个保存在第一行的同一行上 请问我如何解决这个问题 我想要点击它的每个按钮保存到新行
这是收据的代码
def Receipt():
global txtReceipt
txtReceipt.delete("1.0", END)
x = random.randint(10908, 500876)
randomRef = str(x)
Receipt_Ref.set("BILL" + randomRef)
txtReceipt.insert(END, 'Receipt Ref: \t\t\t'+Receipt_Ref.get()+"\t\t"+DateofOrder.get()+"\n")
txtReceipt.insert(END, 'Items\t\t'+'Quantity\t\t\t'+"Price \n\n")
if variable ==1:
txtReceipt.insert(END, str(my_text)+'\t\t'+str(bttn_clicks)+'\t\t\t'+""+str(bttn_clicks*3)+"\n")
if variable ==2:
txtReceipt.insert(END, str(my_text)+'\t\t'+str(bttn_clicks)+'\t\t\t'+""+str(bttn_clicks*3)+"\n")
if variable ==3:
txtReceipt.insert(END, str(my_text)+'\t\t'+str(bttn_clicks)+'\t\t\t'+""+str(bttn_clicks*3)+"\n")
这些是生成按钮的功能
def readqurec():
cur.execute("SELECT name FROM qureec ")
return cur.fetchall()
def showqurec():
global button,data2
data2 = readqurec()
for index, dat in enumerate(data2):
button= ttk.Button(master, text=dat[0],command=lambda dat=dat:update_count(dat))
button.grid(row=index+1, column=0,padx=0, pady=0)
button_dict[dat] = button
def update_count(x):
global bttn_clicks,my_text
my_text=StringVar()
for name in data2:
my_text = button_dict[x].cget('text')
bttn_clicks += 1
感谢所有