簡體   English   中英

在 Tkinter 中需要很長時間的 function 如何處理?

[英]how do you deal with the function that takes a long time in Tkinter?

我正在使用 Tkinter,我有一個 function 需要很長時間才能處理(10 分鍾),所以我想在過程結束之前顯示一個幀,然后顯示 ZC1C425268E68385D1AB5074C 所做的任何事情

class App(customtkinter.CTk):

    WIDTH = 950
    HEIGHT = 520

    def __init__(self):
        super().__init__()

        self.button_3 = customtkinter.CTkButton(
            master=self.frame_left,
            text=" Translation",
            width=160,
            command=lambda: [self.waiting_func(imported_file)])
        self.button_3.grid(row=4, column=0, pady=10, padx=20)

    def waiting_func(self, imported_file):
        fr = Frame(self.frame_right, bg="red")
        fr.grid(row=1,
                column=0,
                rowspan=9,
                columnspan=2,
                pady=20,
                padx=10,
                sticky="nswe")
        Translaion_main(self, imported_file) #this is the functin with the long process

但幀 fr 在過程結束之前(10 分鍾后)不顯示

我試過進度條也不行

有人可以幫忙嗎?

可以創建線程在后台運行任務: https://superfastpython.com/thread-long-running-background-task/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM