我是python新手,当我遇到问题时,我正在创建一个小游戏。我找了一个答案,找到了一个,但没用。在
我尝试做的游戏或多或少是一个曲奇点击器的再创造,我试图制作一个新的标签,我有更新的分数,相反,它创建了一个新的标签。在
from tkinter import *
import time
master = Tk()
def uiPrint():
print("")
print(click)
blankLine()
click = 0
mult = 1
dcp1 = 0
def blankLine():
for i in range(20):
print("")
def buttonCommand():
global click
global mult
click += 1*(mult)
uiPrint()
scoreCommand = Button(text=click)
scoreCommand.pack()
mainClickButton = Button(master, text="Click me!", command = buttonCommand)
mainClickButton.pack()
master.title("Cookie Clicker")
photo = PhotoImage(file=r"C:\Users\---\Desktop\Cookie.gif")
label = Label(image=photo)
label.image = photo
label.pack()
mainloop()
我发现了这个帖子:
Update Tkinter Label from variable
稍加修改这意味着:
我还建议将cookie图像设为按钮:
^{pr2}$这两个版本都用python2.7.11和python3.5.2进行了测试,结果都很好
相关问题 更多 >
编程相关推荐