用变量referen调用Python Tkinter按钮函数

2024-04-27 02:17:37 发布

您现在位置:Python中文网/ 问答频道 /正文

有办法吗

 WoodInt = GatherWood(WoodInt)

在tkinter按钮上?你知道吗

 BWood = tk.Button(Top, text ="Gather Wood", command = GatherWood)

我想做的是,每次按下按钮,WoodInt就会上升20。你知道吗


Tags: texttkintertopbutton按钮commandtk办法
1条回答
网友
1楼 · 发布于 2024-04-27 02:17:37

目前还不清楚GatherWood是怎么做的,但是,一种方法是将您的按钮链接到一个WoodInt递增20的命令:

def increment_woodint_by_20():
    global WoodInt
    Woodint += 20

WoodInt = GatherWood(WoodInt)
BWood = tk.Button(Top, text ="Gather Wood", command=increment_woodint_by_20)
...

相关问题 更多 >