バーが終了したら(3秒間)、プログレスバーウィンドウを表示しようとしていますが、ウィンドウは表示されませんすべてが完了するまで生成します。なぜ、最初にバーを生成するのではなく、ボタンが3秒間スリープするのですか?これをどのように機能させることができますか?このコードは、問題の理解を容易にするために、3つの別々の機能に分かれています。ありがとうございます。完了時にウィンドウを閉じるプログレスバー
from Tkinter import *
from ttk import Progressbar
from time import sleep
def Generate_Invoice(toplevel):
Generating_Label=Label(toplevel, text="Please wait while we generate your invoice...")
progress = Progressbar(toplevel, maximum=100,mode='determinate')
Generating_Label.pack(side=TOP)
progress.pack(fill=X)
progress.start(10)
def Timer(toplevel):
sleep(3)
toplevel.destroy()
def Work():
toplevel=Toplevel()
Generate_Invoice(toplevel)
Timer(toplevel)
window=Tk()
Generate=Button(window, text="Generate invoice",command=Work)
Generate.pack()
window.mainloop()
このコードは、ループ範囲の量のために(100)ウィンドウ 'を初期化する前に上であるために、それが待つだけ異なる同じことを行い["value"] == 100: toplevel.destroy() ' –