I have a tkinter gui with a button and a text field. When the user presses the button several tasks are performed and I want progress of these tasks to be printed to the text box. It seems the GUI does not update until all the tasks are completed then all the text shows up at once. Is there any way to get around this? I'm assigning my button press using button.configure(command = self.button_action)
and the updates to the text field are performed inside the button_action method along with other tasks.
Asked
Active
Viewed 522 times
-2

nanogoats
- 150
- 1
- 8
-
Please read [How to ask](https://stackoverflow.com/help/how-to-ask). Please provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – buhtz Jan 13 '18 at 04:58
-
This question could help you, too: https://stackoverflow.com/q/47895765/4865723 If you provide an full example I could help you more. – buhtz Jan 13 '18 at 04:59
1 Answers
0
Ok I actually figured it out. Just call root.update()
after adding text to the text box. The button depresses prematurely but the other tasks continue on fine.

nanogoats
- 150
- 1
- 8
-
Good that it solved the issue. It sounded like a symptom of one-threaded programming and I was going to suggest using multi-threaded programming to handle multiple events asynchronously. Here is a good SO question to look at for that https://stackoverflow.com/questions/41371815/how-can-i-stop-my-tkinter-gui-from-freezing-when-i-click-my-button – pastaleg Jan 12 '18 at 19:38
-
I wonder if there's another way to do this, though still in a single thread because I don't want the GUI to be usable while the command is being carried out, I just want the gui text box to update with the progress. My current solution depresses the button and allows user to press it again before the command is completed starting another call of it. – nanogoats Jan 16 '18 at 17:14
-
You can call object.pack_forget() where object is the button. This lets the program forget the button. Then call object.pack() when you want to activate it again. – pastaleg Jan 16 '18 at 17:19