Progressbar (ttk.Progressbar) with python in tkinter not showing -


using ttk.progressbar in python (in tkinter gui), i'm trying have progressbar appear when press button. clicking "analyse" button on gui calls function analyze in script, i've meant three-stage rocket of sorts:

  1. grid() progressbar-widget add mainframe, , start() it.

  2. do actual computing (which takes 3 seconds in test-runs)

  3. stop() progressbar , grid_remove() hide user again, job complete.

if comment out step 3, progressbar shown , started expected, while step 2 executed. if step 3 remains, progressbar never shown in first place. now, since work in step 2 being executed either way, i'm assuming might have gridding , removing of progressbar-widget in same function-call, since first real gui project in python, i'm bit @ loss on how work around (if indeed problem). there way around this, or way of more elegantly accomplishing same task? function button calls follows:

def analyze():     # --step 1--     progressbar.grid()     progressbar.start()      # --step 2--     global analysis     analysis = analyzer.analysis(file_path.get())     analysis.output_to_file()      # --step 3--     progressbar.stop()     progressbar.grid_remove() 

i'd post picture of interface clarify further, since current reputation score not allow posting of images, hope i've made problem clear enough explanation (and code).

in order widget appear after being created, event loop must allowed run. because actual drawing of widget on screen happens result of redraw event.

you can call update_idletasks allow event loop service such redraw events, after creating , starting progress bar. however, while calculation running app appear frozen. again, because event loop must allowed service events, can't when doing other things.

the normal way solve problem run long running calculation in thread or separate process.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -