Tk Source Code

View Ticket
Login
2026-10-02
17:35 • Ticket [89436bd2] Aqua/Windows : problem with ttk::progressbar in -mode indeterminate status still Open with 3 other changes artifact: 379ab589 user: serhiy.storchaka
2025-03-06
14:17 • Closed ticket [ef1bfef5]: Error in computing return value of AnimationEnabled for ttk progress bar plus 7 other changes artifact: 11bf79c8 user: marc_culler
05:18 • Open ticket [ef1bfef5]. artifact: 8d88ef59 user: marc_culler
03:33 • Closed ticket [ef1bfef5]. artifact: fddc21a9 user: marc_culler
03:30
Fix [ef1bfef57e]: misplaced parenthesis makes every determinate progress bar be animated closed check-in: 1511d606 user: culler tags: mistake
03:27
Fix [ef1bfef57e]: misplaced parenthesis makes every determinate progress bar be animated check-in: dbce8958 user: culler tags: bug-ef1bfef57e
03:09 • New ticket [ef1bfef5] Error in computing return value of AnimationEnabled for ttk progress bar. artifact: f2d16bb6 user: marc_culler

Ticket UUID: ef1bfef57e05099e93f1eb0960e658def076e424
Title: Error in computing return value of AnimationEnabled for ttk progress bar
Type: Bug Version: 9.0.1
Submitter: marc_culler Created on: 2025-03-06 03:09:54
Subsystem: 88. Themed Tk Assigned To: marc_culler
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2025-03-06 14:17:32
Resolution: Fixed Closed By: marc_culler
    Closed on: 2025-03-06 14:17:32
Description:

I noticed an amazing bug in the implementation of the ttk progress bar when I was looking into [7e28ef577a]. When the loop incrementing the progress bar reached the end, the progress bar was rapidly redisplayed even though nothing was changing. (The value at the end of the loop was 99.) It turned out that AnimationEnabled was returning 1 even though the progress bar was determinate. The cause was a misplaced parenthesis dating back to 2006.

The effect is to make any determinate progress bar be animated almost all of the time. This may explain, at least partly, the reports that progress bars significantly increase CPU usage even when they are not doing anything.

Here is the problematic code:

    return pb->progress.period > 0
	&& value > 0.0
	&& (   value < maximum
	    || pb->progress.mode == TTK_PROGRESSBAR_INDETERMINATE);

The correct code (with extra parentheses for clarity) would be:

    return (pb->progress.period > 0 && value > 0.0 && value < maximum)
	|| (pb->progress.mode == TTK_PROGRESSBAR_INDETERMINATE);

User Comments: marc_culler (claiming to be Marc Culler) added on 2025-03-06 14:17:32:
I think that works.  I will close this now.

marc_culler (claiming to be Marc Culler) added on 2025-03-06 05:18:33:
This turns out to be more complicated than I expected.

First, the manual says that the -period option is only available on Aqua.

Second, the aqua theme sets the default value of the period to 100.

So my proposed fix will not stop the animation.

I think this is left over from macOS 10.6 and older which fetured an
animated barber pole progress bar.  The period determined how fast the
barber pole spun.  Modern macs animate the indeterminate progress bar,
but not the determinate ones.  I am going to change the code so that
the animation only occurs for indeterminate progress bars with positive
period.