我想創建一個不確定的進度條在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()被調用永遠不會出現,如果我跳過此部分,那麼操作後線程執行不會運行