Progress bar value is not updating in tk

Posted by / 07-Dec-2019 13:22

I tried running it on the root window, even though the information you provided indicated that it doesn't matter what class owns the method -- and my experience certainly does not contradict that statement. The only technique I have found that permits the main window to update is to run most of the handler in a separate thread. First, in response to your questions: (1) I am on Linux (there are other platforms?The problem I am having with that approach is that the Message Bar then flashes in an annoying way (the background seems to go to white at every update and then gets redrawn to gray -- which happens only when the while loop is in its own thread). ); (2) I am using Python 2.3; (3) it is difficult to extract a piece of the code, but I will attempt to describe more clearly what I am doing. In the handler I use popen3 to launch a program that takes a long time to execute.Like most GUI systems, Tkinter is basically a single threaded system.It'll run the current task until finished, then process the next event.update_idletasks gives it a chance to handle other events. Typically a long-running task should be run as a separate background thread (or even a separate process).

I tried running it on the root window, even though the information you provided indicated that it doesn't matter what class owns the method -- and my experience certainly does not contradict that statement. The only technique I have found that permits the main window to update is to run most of the handler in a separate thread.I monitor its progress in a while loop by reading a status line that it produces on stderr.The status line provides information about percentage complete; I use that information to update the Message Bar in my GUI.Do I have to run the update_idletasks method for every widget in the GUI? -- Jeffrey Barish I'm confused about how to use the update_idletasks method.In myprogram, I have a handler for a button in which execution will linger.

progress bar value is not updating in tk-73progress bar value is not updating in tk-5progress bar value is not updating in tk-68

The most straightforward technique is to transfer data from the background thread to the main thread via a Queue object (as usual), then poll the background thread's Queue (by repeatedly calling after to do a nonblocking read on the Queue object). The handler will run in the main thread, and so can safely update the GUI.