函数运行tkinter冻结。 我想用Tkinter窗口运行它过程。而运行进度条 我想用特金特窗户。但是我不能 因为它冻结了tkinter。我如何使用根窗口时间。睡眠(10) 或其他功能正在工作
import tkinter.ttk as ttk
import tkinter as tk
import time
progress = 0
def loading(window=None):
mpb = ttk.Progressbar(window, orient="horizontal", length=200, mode="determinate")
mpb.place(y=0, x=0)
mpb["maximum"] = 100
mpb["value"] = progress
print(progress)
def incrase():
global progress
print(progress)
progress += 1
time.sleep(10) # for example, a function works here and tkinter freezes
loading() # i don't want tkinter freezes
root = tk.Tk()
loading(root)
ttk.Button(root, text='increase', command=incrase).place(x=0, y=25, width=90)
root.mainloop()
谢谢你的回答
应该使用^{} ,通过它可以安排
loading()
函数在一段时间后调用。你知道吗程序
以下是如何在程序中使用它:
演示
以上运行程序截图:
相关问题 更多 >
编程相关推荐