我想创建一个不确定的进度条在python 3在新的顶级窗口的某些过程,然后启动该进程的线程。我想要的是进度条启动并且线程也在后台启动,一旦线程完成执行,一些消息显示任务已完成。如何创建一个不确定的进度,并在后台启动一个线程,并在Python中完成线程后再次执行一些操作
代码:
class myThread(threading.Thread):
def __init__(self, threadID):
threading.Thread.__init__(self)
self.threadID = threadID
def run(self):
print("Starting the thread")
func()
print("Ending the thread")
def func():
some task
...
new_top = Toplevel()
new_top.title("New Top Level")
new_top.geometry("400x170")
label = Label(new_top, text='Doing some work', justify=CENTER, bg="#CBFDCB").place(x=43,y=30)
progress_bar = ttk.Progressbar(new_top, orient="horizontal", mode="indeterminate", takefocus=True, length=320)
progress_bar.place(x=40, y=80)
progress_bar.start()
thread1 = myThread(1)
thread1.start()
thread1.join()
...
执行后的线程操作
我的问题是什么,带标签和进度条的顶层窗口,如果thread1.join()被调用永远不会出现,如果我跳过此部分,那么操作后线程执行不会运行