python - 带有单击按钮的 tkinter 定义
问题描述
我尝试让我的一个定义单击我的 GUI 的一个按钮来运行另一个定义:
def1():
#### I don't know the code here
def2():
print("Hello World")
window = Tk()
button1 = Button(window, text="click 2nd button", command = lambda: threading.Thread(target=def1).start())
button2 = Button(window, text="2nd button", command = lambda: threading.Thread(target=def2).start())
这只是一个简单的例子,我不能def2()
直接运行def1()
,因为第一个和第二个定义需要很多时间,我使用线程让两个定义同时运行。我需要类似click(button2)
in 的东西def1()
。
解决方案
推荐阅读
- java - spring如何在mongoDB中查询过滤
- flutter - Flutter 在 Stack 小部件中显示 2 小部件
- sql - 如何创建触发器以发送电子邮件
- c# - c#中的并行任务性能
- javascript - 如何将应用程序状态保存到 cookie
- xml - 如何在 Android Studio 中创建可滚动的线性布局?
- azure - Graph Api 响应中的 nextLink 不是绝对 Uri
- c# - Http Utility '在当前上下文中不存在(API 帮助)
- python - 对多个 CSV 中的值求和 python
- sql-server - T-SQL 到 XML 的嵌套和拆分