【问题标题】:Pausing until button in pressed in Python暂停直到在 Python 中按下按钮
【发布时间】:2016-01-25 15:43:47
【问题描述】:

我试图弄清楚如何暂停代码执行,直到在 Tkinter 中按下按钮。我找到了键盘输入的示例,但正在寻找一种使用按钮进行相同操作的方法。

提前致谢!

【问题讨论】:

  • 您的问题在 Tkinter 应用程序的上下文中没有意义。 tkinter 应用程序已经一直处于等待状态。你能写一个非常短的程序来说明你想要做什么吗?

标签: python button tkinter pause


【解决方案1】:

可能是这样的:

from tkinter import *

root = Tk()

def mainfunction():
    #stuff your program is supposed to do


runmain = False

def runtheprogram():
    runmain = True

b1 = Button(root, text="Start", command=runtheprogram)
b1.pack()

if runmain:
    mainfunction()

root.mainloop()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    • 2022-01-06
    • 2022-01-10
    • 2017-07-03
    • 2018-07-16
    相关资源
    最近更新 更多