Sujet : Re: "update idletasks" doesn
De : user2230 (at) *nospam* newsgrouper.org.invalid (nab)
Groupes : comp.lang.tclDate : 05. Mar 2025, 16:21:31
Autres entêtes
Message-ID : <1741188091-2230@newsgrouper.org>
References : 1
User-Agent : Newsgrouper/0.7.0
Eric Brunel <
eric.brunel@pragmadev.com> posted:
Hello all,
I have an installation of tcl/tk 9.0.1 compiled from source on a mac mini
with macOS 13.2, and I found out something quite weird: it seems that
"update idletasks" has no effect at all on this platform, when it works as
expected on Windows and Linux.
Here is a script showing the problem:
-----------------------------------
ttk::progressbar .pbar -mode determinate -value 0 -length 300
pack .pbar -side top -padx 8 -pady 8
proc compute { x0 } {
set x $x0
while { $x > 1 } {
if { $x % 2 == 0 } {
set x [expr $x / 2]
} else {
set x [expr 3 * $x + 1]
}
}
}
proc run {} {
. configure -cursor watch
update idletasks
for { set i 0 } { $i < 100 } { incr i } {
for { set j 0 } { $j < 500 } { incr j } {
compute [expr $i + 1000]
}
.pbar configure -value $i
update idletasks
}
. configure -cursor ""
}
ttk::button .btn -text "Go!" -command run
pack .btn -side bottom -padx 8 -pady 8
-----------------------------------
If I run this on Windows or Linux, I can see the progress bar being
updated after I click the "Go!" button. If I do the same on macOS, the
window is stuck in its initial state, and the display is updated only when
everything is finished.
Note that the problem strangely does not happen when the computation is
replaced by a "after 100" for example. In this case, the display is
updated. But the script is actually doing something, it doesn't seem to
work. Replacing "update idletasks" with just "update" works, but
sometimes, you just don't want to handle pending events.
Can anybody confirm they have the same issue? I'd like to be sure it's not
something in my build that causes the problem before creating a ticket.
Thanks!
Hi,
according to the doc there's no -configure option for ttk::progressbar
++