Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My Tkinter GUI is too ... static?

Tags:

python

tkinter

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?

like image 513
Jakob Avatar asked Nov 05 '22 13:11

Jakob


1 Answers

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 :)

like image 83
Jere Avatar answered Nov 14 '22 21:11

Jere