My Tkinter GUI is too ... static?
I use a Tkinter GUI to intiate a measurement and analysis process, which basically gets going with a开发者_如何学编程 clicked button. Since those measurements can take a while, I tried to include a progress bar, namely this one:
http://tkinter.unpythonic.net/wiki/ProgressMeter
But when I do initiate the process, my whole Tkinter window turns into nonsense until the measurement is done and it kinda reloads itself, with my progress bar set too 100%. This is kinda not what I wanted to happen.
What happened there? I am pretty new to this whole programming thing, so I don't have all the tools I guess. Do I need to introduce a seperate thread or something like that, so that the measurement and the tkinter mainloop (is that what that is?) run simultaneously? If so, how do I do that?
Make a progressbar (these are snippets from my code that processes a 67MB file.)
progress = ttk.Progressbar(bottommenuframe, orient=HORIZONTAL, length=100, maximum=190073, mode='determinate')
progress.pack(side=RIGHT)
progress.start() ## this starts the progressbar
then during your analysis:
def analysisfunction():
progress.step(1)
##do some analysis
root.after(0, analysisFunction)
if job == complete:
stop
Like I said this will work with my 67MB file and tkinter. Hope that helps a little :)
call widget.update()
/ root_window.update()
each time you update the progress bar
精彩评论