Tk Library Source Code

View Ticket
Login
Ticket UUID: 68d110104cc46b715811e4a877a7b5e47c6aa27b
Title: Plotchart bug with Tk trunk
Type: Bug Version: trunk
Submitter: emiliano Created on: 2024-10-18 00:30:06
Subsystem: tklib :: plotchart Assigned To: arjenmarkus
Priority: 5 Medium Severity: Critical
Status: Closed Last Modified: 2024-10-20 14:44:02
Resolution: Fixed Closed By: arjenmarkus
    Closed on: 2024-10-20 14:44:02
Description:
Running this slighltly modified example from the docs

package require Plotchart
canvas .c -background white
pack   .c -fill both
set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
foreach {x y} {0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 } {
    $s plot series1 $x $y
}
$s title "Data series"

with Tk trunk results in an error:

expected integer but got "10c"
    while executing
"incr width -[$w cget -borderwidth]"
    (procedure "WidthCanvas" line 19)
    invoked from within
"WidthCanvas $w"
    (procedure "MarginsRectangle" line 78)
    invoked from within
"MarginsRectangle $w $argv"
    (procedure "CreateXYPlotImpl" line 16)
    invoked from within
"CreateXYPlotImpl xyplot $w $xscale $yscale $args"
    (procedure "::Plotchart::createXYPlot" line 3)
    invoked from within
"::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 {set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]}"

This is due to changes in Tk option defaults

$ echo 'canvas .c; puts [.c cget -width]; exit' | wish8.6 
379
$ echo 'canvas .c; puts [.c cget -width]; exit' | wish9.0 
10c

Attached patch solves the issue by calling [winfo pixels] where appropriate
User Comments: arjenmarkus added on 2024-10-20 14:44:02:
New version is 2.7.0.

Unrelated change: using an initialisation proc to take care of the change in semantics in Tcl 9 for namespace variables outside a proc context.

arjenmarkus added on 2024-10-20 14:42:22:
I have applied the patch - had to make some additional changes though (these have to do with the naming convention used by Plotchart to distinguish multiple plots in the same canvas/window.

I verified that all tests succeed.

Attachments: