summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorcsaba <csaba>2023-07-07 19:00:43 (GMT)
committercsaba <csaba>2023-07-07 19:00:43 (GMT)
commit0c63cb8e6bd7d8adab46c43f41972130eac48270 (patch)
tree03b5b7dba8eeed231712c619300c4fe22752a9be /library
parent5716e8bf8846b0ec1b507ee2199da2c575ae3291 (diff)
downloadtk-0c63cb8e6bd7d8adab46c43f41972130eac48270.zip
tk-0c63cb8e6bd7d8adab46c43f41972130eac48270.tar.gz
tk-0c63cb8e6bd7d8adab46c43f41972130eac48270.tar.bz2
Widget Demo: Optimized the size of the canvas used in the script floor.tcl.
Diffstat (limited to 'library')
-rw-r--r--library/demos/floor.tcl16
1 files changed, 11 insertions, 5 deletions
diff --git a/library/demos/floor.tcl b/library/demos/floor.tcl
index f3daac4..81920ed 100644
--- a/library/demos/floor.tcl
+++ b/library/demos/floor.tcl
@@ -54,7 +54,7 @@ proc floorDisplay {w active} {
$w raise room
# Rescale the coordinates in pixels of all of the
- # items according to the display's DPI scaling level
+ # items according to the display's DPI scaling level.
set scaleFactor [expr {$tk::scalingPct / 100.0}]
$w scale all 0 0 $scaleFactor $scaleFactor
@@ -69,7 +69,14 @@ proc floorDisplay {w active} {
$w create window 450p 75p -anchor w -window $w.entry
$w create text 450p 75p -anchor e -text "Room: "
- $w config -scrollregion [$w bbox all]
+ # Configure the canvas.
+
+ set bbox [$w bbox all]
+ lassign $bbox x1 y1 x2 y2
+ set morePx [expr {round(20 * $tk::scalingPct / 100.0)}]
+ set width [expr {$x2 - $x1 + $morePx}]
+ set height [expr {$y2 - $y1 + $morePx}]
+ $w configure -scrollregion $bbox -width $width -height $height
}
# newRoom --
@@ -1317,9 +1324,8 @@ pack $f -side top -fill both -expand yes
set h [ttk::scrollbar $f.hscroll -orient horizontal]
set v [ttk::scrollbar $f.vscroll -orient vertical]
set f1 [frame $f.f1 -borderwidth 2 -relief sunken]
-set c [canvas $f1.c -width 675p -height 375p -highlightthickness 0 \
- -xscrollcommand [list $h set] \
- -yscrollcommand [list $v set]]
+set c [canvas $f1.c -highlightthickness 0 \
+ -xscrollcommand [list $h set] -yscrollcommand [list $v set]]
pack $c -expand yes -fill both
grid $f1 -padx 1 -pady 1 -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
grid $v -padx 1 -pady 1 -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news