In tkcon, the [puts] command calls [update idletasks]. This can cause very weird errors that are hard to indentify if one does not know that.
Here's a simple (and silly) example that illustrates the issue:
package require Tk 8.6 label .l1 -text "Label 1" label .l2 -text "Label 2" button .b -text "Start test" -command {startTest} grid .l1 grid .l2 grid .b bind .l1 <Configure> {confProc %W} bind .l2 <Configure> {confProc %W} proc startTest {} { .l1 configure -width 20 puts "configured .l1" .l2 configure -width 20 puts "configured .l2" return } proc confProc {w} { puts "ConfigureEvent for $w" return }
Pressing the "Start test" button, one would expect this output:
configured .l1 configured .l2 ConfigureEvent for .l2 ConfigureEvent for .l1
Instead, the result is:
configured .l1 ConfigureEvent for .l2 ConfigureEvent for .l1 configured .l2 ConfigureEvent for .l2
The problem seems to be known. Around line 3800, tkcon.tcl says:
## WARNING: This update should behave well because it uses idletasks, ## however, if there are weird looping problems with events, or ## hanging in waits, try commenting this out. if {$len} { tkcon console see output update idletasks }
Commenting out that line does indeed solve the problem. The downside is that, without that [updtade], the output of a longer task will show only after it is complete.
I am aware that there is no perfect solution to this problem (at least, I couldn't think of any).
A few things could be improved, though: