Is there a limit for the value of the attribute "width" of a canvas ?
In the following example, I create a Canvas in a ScrolledWindow.
# Packages
package require BWidget
# Mainframe
set mfr [MainFrame .mfr -textvariable "Test"]
pack $mfr -fill both -expand yes
# Create a Paned Window with two panes
set pw1 [PanedWindow [$mfr getframe].pw1 -side left]
set pat [$pw1 add -minsize 200]
set pai [$pw1 add -minsize 200]
pack $pw1 -fill both -expand yes -anchor nw
# Create a frame for each pane
set tft [TitleFrame $pat.tft -text "Scrollable Canvas"]
set tfi [TitleFrame $pai.tfi -text "Informations"]
pack $tft -fill both -expand yes -anchor nw
pack $tfi -fill both -expand yes -anchor nw
# Create a canvas inside a ScrolledWindow for the first pane
set swt [ScrolledWindow [$tft getframe].swt -relief sunken -borderwidth 2 -scrollbar horizontal -auto none]
set sft [ScrollableFrame $swt.sft -width 50000 -height 200]
$swt setwidget $sft
set tab [canvas [$sft getframe].tab -width 50000 -height 200 -background black]
# Draw an horizontal line on the canvas
$tab create line 0 100 50000 100 -width 1 -fill white
pack $tab -fill both -expand yes -anchor nw
pack $swt -fill both -expand yes -anchor nw
# Create a ScrolledWindow for the second pane
set swl [ScrolledWindow [$tfi getframe].swl -relief sunken -borderwidth 2 -scrollbar vertical -auto both]
pack $swl -expand yes -fill both
# Display the window manager
wm minsize . 600 350
wm deiconify .
wm protocol . WM_DELETE_WINDOW {exit}
bind . <Control-q> {exit}
In this example, I used a width of "50 000" for the canvas, but when I use the scrollbar the black box of the canvas ends before. The same issue also affects the horizontal line which is drawn on the canvas.
Do I missed something ? Is there a known limit for the "width" attribute of the canvas ?
Thanks for your help
Things get a bit funky if you make them larger than 32,000 (strictly 32767, the limit of a signed C short
) particularly at the rendering layer (and definitely don't make the canvas viewport that size!). However, the underlying canvas model uses IEEE double
s to store the coordinates, so there's no reason why you couldn't have things go off that far. You just must keep the size of individual objects down.
This is all a legacy of X11, which uses 16-bit values for coordinates and dimensions in quite a few key structures. Changing this is both logically easy and a lot of work in practice (the assumptions are all over the place).
来源:https://stackoverflow.com/questions/26578213/is-there-a-limit-for-the-width-of-a-canvas