我正在尝试编写我的游戏代码(我才刚开始使用Tkinter),但这一点不断出现
UnboundLocalError: local variable 'money' referenced before assignment
以下是我尝试的代码:
from tkinter import *
root = Tk()
money = 0
click = 1
def earnmoney():
money = money + click
def showmonney():
Total_money.configure(text = money)
root.title("MONEY")
root.geometry("1000x500")
app = Frame(root)
app.grid()
label = Label(app, text = "Press the button to earn money")
label.grid()
button1 = Button(app, text = "Earn money", command=earnmoney)
button1.grid()
button2 = Button(app, text = "Show money", command=showmonney)
button2.grid()
Total_money = Label(app)
Total_money.grid()
root.mainloop()
目前没有回答
相关问题 更多 >
编程相关推荐