Posted to tcl by bleb at Tue Nov 07 18:12:14 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
- foreach i { 1 2 3 } {
- puts "i: $i"
- $t tag bind link$i <1> {$t insert end "CLICK: $i\n"}
- $t insert end "-> $i <-\n" link$i
- }