|
2019-01-17
| ||
| 18:13 | • Closed ticket [9ad28e91c0]: ProgressbarStepCommand sets value to 0 when reaching... artifact: 45fe63a8c5 user: bll | |
| 15:51 | • New ticket [9ad28e91c0]. artifact: ef35d5cf5c user: anonymous | |
ProgressbarStepCommand sets value to 0 when reaching maximum
Closed / Invalid9ad28e91c089f89cb28999b08b66ec1e3726e71bCreated 8 years agoUpdated 8 years ago
Descriptionplain2019-01-17 15:51:32
Summary: ProgressbarStepCommand’s behaviour differs from what is mentioned in its comments. If value reaches maximum exactly, the fmod() call resets it to 0. Details: I’m using Python’s tkinter, but could track down the bug I found to the Tcl/Tk source. My code iterates through a number of items; I set the progressbar maximum to that number and call the progressbar step command in each iteration to increase by 1. For example, with maximum = 42: after the first iteration, the value is 1.0, after the second it is 2.0 and so on until the second-to-last iteration, when it is 41.0. But on the last iteration, the value is reset to 0.0, resulting in an empty progress bar at the end of my computations. If I set value to maximum directly (without using successive calls to step), the progressbar is full, and when I read back the value it is equal to maximum. So code outside of ProgressbarStepCommand handles this case differently. The comment in ProgressbarStepCommand (file generic/ttk/ttkProgress.c) says: “In determinate mode, wrap around if value exceeds maximum”. Please note that wrap-around should occur when value *exceeds* maximum, which makes sense. The code however is: value = fmod(value, maximum) This already wraps around to 0.0 when value is *equal* to maximum. My suggestion: test for value > maximum, only then call fmod() Thanks!
bllplain2019-01-17 18:13:05
Copied to: https://core.tcl.tk/tk/tktview/7bf9bd3a6e4adb46a5b747758ca9b065a2a0bb92 as this is a Tk issue.
Log in (anonymous is fine) to add a comment.