Chris Bao
Chris Bao

Reputation: 2888

TCL/TK: insert message into text widget real time while the program running

I develop a tool with tcl and tk.
In the backend, tcl handles big data file in multiple steps.
I add a text widget on the tk GUI.
And want to use it as a status message box, showing which step is running now.
But it seems that, during the data handling, the GUI is fixed.
The message can not be inserted in real time, instead all the messages will be added into the text area after the program finished.
Is there some method to insert the message into text real time?

Upvotes: 1

Views: 747

Answers (1)

Jerry
Jerry

Reputation: 71578

You can make use of update idletasks each time a step is complete.

# first step here

# reconfigure labels and other widgets

update idletasks

# second step

# reconfigure labels and other widgets

update idletasks

This will push any changes to be performed to the GUI before executing the next step.

Note that you shouldn't need another update idletasks after the last step if there are no other further immediate processing.

Upvotes: 2

Related Questions