Posted to tcl by jdc at Fri Jun 20 07:30:58 GMT 2008view raw
- package require Tk
- set ltxt [text .ltxt]
- set rtxt [text .rtxt -xscrollcommand [list .sx set]]
- set sx [scrollbar .sx -orient horizontal -command [list $rtxt xview]]
- set sy [scrollbar .sy -orient vertical]
- proc yset { t1 t2 sy args } {
- $t1 yview moveto [lindex $args 0]
- $t2 yview moveto [lindex $args 0]
- eval $sy set $args
- }
- proc yview { t1 t2 sy args } {
- eval $t1 yview $args
- eval $t2 yview $args
- }
- $ltxt configure -yscrollcommand [list yset $ltxt $rtxt $sy]
- $rtxt configure -yscrollcommand [list yset $ltxt $rtxt $sy]
- $sy configure -command [list yview $ltxt $rtxt $sy]
- grid $ltxt $rtxt $sy -sticky ewns
- grid $sx - -sticky ewns
- grid columnconfigure . 0 -weight 1
- grid rowconfigure . 0 -weight 1
- for {set i 0 } { $i < 100 } { incr i } {
- $ltxt insert end "left $i\n"
- $rtxt insert end "right $i\n"
- }