home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / tcl / 2315 < prev    next >
Encoding:
Text File  |  1993-01-07  |  1.5 KB  |  49 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!caen!spencer
  3. From: spencer@med.umich.edu (Spencer W. Thomas)
  4. Subject: Re: scrolling two lists
  5. Message-ID: <SPENCER.93Jan7140121@guraldi.med.umich.edu>
  6. Date: Thu, 07 Jan 93 14:01:21 EST
  7. Organization: University of Michigan
  8. In-Reply-To: news@choreo.ca's message of Tue, 05 Jan 1993 20:33:10 GMT
  9. References: <1993Jan05.203310.11620@choreo.ca>
  10. Nntp-Posting-Host: guraldi.itn.med.umich.edu
  11. Lines: 36
  12.  
  13. In article <1993Jan05.203310.11620@choreo.ca> news@choreo.ca (Choreo NetNews Administration Account(Ottawa)) writes:
  14. > I have two listboxes which contain related information.  When one list is
  15. > scrolled I want the other scrolled for the same motion.  In addition, I want
  16. > to use only one scroll bar to control the two lists.
  17.  
  18. Try this
  19.  
  20. listbox .l1 -relief raised -yscroll {lscroll .l2}
  21. listbox .l2 -relief raised -yscroll {lscroll .l1}
  22. scrollbar .s -orient vertical -command {lview}
  23.  
  24. # Scroll both listboxes from the scrollbar
  25. proc lview {where} {
  26.   .l1 yview $where
  27.   .l2 yview $where
  28. }
  29.  
  30. # Scroll the other listbox and the scrollbar
  31. proc lscroll {what total window first last} {
  32.   $what yview $first
  33.   .s set $total $window $first $last
  34. }
  35.  
  36.  
  37. foreach l {a b c d e f g h i j k l m n o p} {
  38.   .l1 insert end $l
  39.   .l2 insert end $l
  40. }
  41.  
  42. pack append . .l1 {left filly} .l2 {left filly} .s {left filly}
  43.  
  44.  
  45. --
  46. =Spencer W. Thomas         |  Info Tech and Networking, B1911 CFOB, 0704
  47.    "Genome Informatician"    |  Univ of Michigan, Ann Arbor, MI 48109
  48. Spencer.W.Thomas@med.umich.edu    |  313-747-2778, FAX 313-764-4133
  49.