我正在嘗試為我的小企業創建一個非常簡單的忠誠度計劃。這是我在 Python 或 Tkinter 中的第一個項目。下面的#POINT ENTRY 部分允許用戶輸入適當的點數。然后它使用“addpoints”從文本文件(擴展名為“.cust”)中提取當前點,并添加用戶輸入的內容并將其寫回文本文件。不幸的是,它實際上只是將整行替換為“.!Entry26”任何指導將不勝感激。#POINT ENTRYpointlabel = Label(root, text="Enter Earned/Spent Points")pointlabel.pack()pointlabel.place(x = 46, y = 95)pointenter = Entry(root, bg="#E9E9E9")pointenter.config(font="bold")pointenter.pack()pointenter.place(x = 50, y = 120, height="30", width="140")addbutton = Button(root, bg="green", fg="white", text=" + ", command=addpoints)addbutton.config(font='bold')addbutton.pack()addbutton.place(x = 201, y = 118)subbutton = Button(root, bg="red", text="-")subbutton.config(font='bold')subbutton.pack()subbutton.place(x = 251, y = 118)def addpoints(): file = open("assets\\" + IDentry.get() + ".cust", 'r+') currpts = file.read(0) updatepoints = sum(currpts, pointenter) file.write(str(updatepoints)) file.close()
添加回答
舉報
0/150
提交
取消