| Ticket UUID: | b845a924db12c9f62ee15a483f068644679020f9 | |||
| Title: | Tachometer : a wrong angle is calculated in method drawline | |||
| Type: | Bug | Version: | Tklib 0.7 | |
| Submitter: | anonymous | Created on: | 2020-09-20 11:05:56 | |
| Subsystem: | tklib :: controlwidget | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Open | Last Modified: | 2026-11-15 23:40:01 | |
| Resolution: | None | Closed By: | nobody | |
| Closed on: | ||||
| Description: |
in tachometer.tcl
a wrong angle is calculated when both -min and -max are set to an integer value, and the value is integer
In the example included in the source file, this fails:
set ::value2 1
controlwidget::tachometer .t2 -variable ::value2 -min 0 -max 10
This works
set ::value2 1
controlwidget::tachometer .t2 -variable ::value2 -min 0.0 -max 10
controlwidget::tachometer .t2 -variable ::value2 -min 0 -max 10.0
controlwidget::tachometer .t2 -variable ::value2
In method drawline, When min, max and v are integers, the calculation of the angle is done using integer division, and the result truncated.
the line
set v [expr { ($value <= ($max*1.02))? $value : ($max*1.02) }]
could be changed to
set v [expr { ($value <= ($max*1.02))? $value*1.0 : ($max*1.02) }]
to enforce floating point division
| |||
| User Comments: |
serhiy.storchaka added on 2026-11-15 23:40:01:
Proposed fix in branch tachometer-needle-angle. The angle is now computed in floating point. The branch also fixes another problem: with Tk 9 the tachometer failed with its default size, because cget -width of the canvas returns "50m" instead of pixels. | |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki