Posted to tcl by bleb at Tue Nov 07 18:45:11 GMT 2023view raw
- #!/usr/bin/wish
- proc Scrolled_Text { f args } {
- frame $f
- eval {text $f.text -wrap none \
- -xscrollcommand [list $f.xscroll set] \
- -yscrollcommand [list $f.yscroll set]} $args
- scrollbar $f.xscroll -orient horizontal \
- -command [list $f.text xview]
- scrollbar $f.yscroll -orient vertical \
- -command [list $f.text yview]
- grid $f.text $f.yscroll -sticky news
- grid $f.xscroll -sticky news
- grid rowconfigure $f 0 -weight 1
- grid columnconfigure $f 0 -weight 1
- return $f.text
- }
- set t [Scrolled_Text .f -width 40 -height 8]
- pack .f -side top -fill both -expand true
- set l [list a b c]
- foreach i {0 1 2} {
- puts "i: [lindex $l $i]"
- $t tag bind link[lindex $l $i] <1> {$t insert end "CLICK: [lindex $l $i]\n"}
- $t insert end "-> $i <-\n" link[lindex $l $i]
- }