我正在使用Tinter制作一款类似cookie点击器的游戏。但我需要有一段时间的True循环才能让钱继续上涨,但与此同时,用户需要能够点击按钮并购买投资,最重要的是点击按钮。有没有办法做到这一点?
from tkinter import *
import time
import tkinter
top = tkinter.Tk()
balance = 0
balmultiplier = 0
wishwells = 0
def clickmain():
global balance
global balmultiplier
balance += 5 + balmultiplier
Number.config()
buttonmain = tkinter.Button(top, text ="Click here!", command = clickmain)
def buywishwell():
global balance
global wishwells
global balmultiplier
if balance >= 100 + (wishwells * 2):
balance -= 100 + (wishwells * 2)
wishwells += 1
balmultiplier += 5
print("\nYou have purchased a Wishing Well!\n")
else:
print("\nYou can't afford that..\n")
mb= Menubutton ( top, text="Investments")
mb.grid()
mb.menu = Menu ( mb, tearoff = 0 )
mb["menu"] = mb.menu
mb.menu.add_checkbutton (label="Wishing Well - £"+str(100 + (wishwells * 2)), command=buywishwell)
info = Message( top, text="Purchases:\n Wishing Wells: "+str(wishwells) )
balvisual = Message( top, text="Your balance is "+str(balance))
mb.pack()
buttonmain.pack()
balvisual.pack()
info.pack()
top.mainloop()