Tk Source Code

Artifact [5fb62f07]
Login

Artifact 5fb62f075acbed2514bf67582973419036df24dd098af5f844830f639b5941de:

Attachment "imagetest.tcl" to ticket [9438cce0] added by nemethi 2026-05-26 19:46:56.
# Create a scrollable canvas
ttk::scrollbar .vsb -command {.c yview}
canvas .c -yscrollcommand {.vsb set}
pack .vsb -side right -fill y
pack .c -side left -expand 1 -fill both

# Create a frame as a window item within the canvas
set f [frame .c.f]
.c create window 0 0 -anchor nw -window $f
bind $f <Configure> {
    [winfo parent %W] configure -scrollregion [list 0 0 %w %h]
}

# Populate the frame
set img [image create photo -file $tk_library/images/logoLarge.gif]
for {set row 0} {$row < 60} {incr row} {
    set l0 [label $f.l$row,0 -image $img -borderwidth 2 -relief ridge]
    set l1 [label $f.l$row,1 -image $img -borderwidth 2 -relief ridge]
    grid $l0 $l1
}

# Set the canvas' width and height
.c configure -width  [expr {2 * [winfo reqwidth $l0]}]
.c configure -height [winfo reqheight $l0]