我正在尝试使用一个按钮在我正在开发的基于文本的游戏上留下特定的场景,为此我准备了一个按钮。但是,由于某些原因,应该在按下按钮之前就执行了按钮应该运行的功能。到目前为止,我只测试了打印内容和检查变量。 Shopchoices1()
函数没有问题,因为它可以独立工作。
无论如何,这是代码:
def thing():
leave=0
def leevefunct(leave):
leave=leave+1
return leave
if leave==0:
canvas.create_rectangle(0,0,1440,810,fill="black")
Shopchoices1()
canvas.create_text(720,415,text=shoplist,font="Times 25",fill="white")
canvas.create_text(720,705,text=backpacklist,font="Times 20",fill="white")
Leaveb1= Button(canvas, text="Leave", command=leevefunct(leave), anchor="n")
Leaveb1.configure(width = 100, bg="yellow",activebackground = "#FFD700", relief = FLAT)
Leaveb1_window = canvas.create_window(720,455, anchor="n", window=Leaveb1)
thing()
mainloop()