小问题有大难度 高手们都来看看!!
下面是我自己做的一个类似收银的程序,可是在最后”remove“按键的时候,可以删除选择的东西,但是在total里面价钱没有删掉,怎么可以做到按了remove按钮,价钱也会同时删除呢?
import Tkinter
from Tkinter import *
import MySQLdb
window = Tkinter.Tk()
window.title("ETrolley")
window.geometry("500x360")
window.configure(bg="#cdc9c9")
title3=Label(window,text="",bg="#cdc9c9")
title1 = Label(window, text="------WELCOME TO ETrolley CHECKOUT------", bg="#cdc9c9")
title2 = Label(window, text="--Please scan your items--", bg="#cdc9c9")
barcodetitle = Label(window, text="---barcode---", bg="#cdc9c9")
itemtitle = Label(window, text=" Item_id | Item | Description | Price ", bg="#cdc9c9")
barcode = Entry(window)
item = Text(window, height=4, width=35)
total = Text(window, height=1, width=5)
t1= Label (window,text="TOTAL", bg="#cdc9c9")
c1=Button(window,text="CHECKOUT",bg="#93ff00")
scroll = Scrollbar(window,orient=VERTICAL, bg="#93ff00")
scroll.config (command=item.yview)
item = Listbox(window,yscrollcommand=scroll.set,width=55,height=30,selectmode=EXTENDED)
title4=Label(window,text="",bg="#cdc9c9")
def one():
user_input=barcode.get()
mycursor = db.cursor()
mycursor.execute("""SELECT barcode, name, description,price FROM product
WHERE barcode = %s""", (user_input,))
# calls fetchone until None is returned (no more rows)
for row in iter(mycursor.fetchone, None):
bar=row[0]
name=row[1]
des=row[2]
pri=row[3]
total.insert(END,row[3])
item.insert(END,row)
barcode.delete(0, 'end')
def delete():
item.delete(ACTIVE)
close = Button(window, text="remove",width=5, command=delete, bg="#ff4500")
go = Button(window, text="add!", command=one, bg="#93ff00")
title3.pack()
title1.pack()
title2.pack()
barcodetitle.pack()
barcode.pack(side=TOP);close.pack(side=RIGHT)
go.pack(side=TOP)
itemtitle.pack()
c1.pack(side=BOTTOM)
t1.pack(side=LEFT)
total.pack(side=LEFT)
scroll.pack(side=RIGHT,expand=1,fill=Y)
item.pack(side=LEFT,expand=0,fill= Y)
title4.pack()
#t1.pack()
window.mainloop()
如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

评论(4)

def delete()
itemText = #000000;">item.get(000000;">ACTIVE)
#000000;">000000;">
item.delete(ACTIVE)
解析价格,
#000000;">此外你000000;">totle的计算还存在问题
totleValueText = total.get(1.0,END)
totleValue = 0
if totleValueText !='n':
totleValue = int(totleValueText)
for row in iter(mycursor.fetchone, None):
bar=row[0]
name=row[1]
des=row[2]
pri=row[3]
totleValue = totleValue + pri
total.delete(1.0,END);
total.insert(END,totleValue)
item.insert(END,row)
#000000;">000000;">#000000;">000000;">
发布评论
需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。