home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / tcl / 2331 < prev    next >
Encoding:
Internet Message Format  |  1993-01-11  |  2.6 KB

  1. Path: sparky!uunet!spool.mu.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!rpi!gatech!cae!cae!usenet
  2. From: estephen@whosnext.cad.gatech.edu (Eric R Stephens)
  3. Newsgroups: comp.lang.tcl
  4. Subject: canvas and  scrolling text field
  5. Date: 11 Jan 1993 13:59:36 GMT
  6. Organization: Georgia Institute of Technology, CAE/CAD Lab
  7. Lines: 63
  8. Message-ID: <1irug8INN8d6@cae.cad.gatech.edu>
  9. NNTP-Posting-Host: whosnext.cad.gatech.edu
  10. Keywords: wish, canvas, scrolling field
  11.  
  12. I'm trying to impliment a scrolling text field within a scrolling
  13.  canvas ($c).  I'm define a frame ($c.$name_frame) with a text
  14. ($c.$name_frame.$name) and a scroll ($c.$name_frame.scroll).  I then  
  15. create a window widget inside the canvas.  
  16.         This all seems to work find until I enter or insert more text  
  17. than can be shown (about 1 line more) and then tvtwm crashes.  Any  
  18. ideas?
  19.  
  20. 3.0: Does not crash but also does not respond to yview.
  21.  
  22. #Sorry about the cut up looking code.
  23.  
  24. #create a toplevel window .win
  25. #.win contains a canvas, two scrolls, and a quit button
  26. #.win.frame2.c contains a frame acting as a scrollable text field
  27.  
  28. #Tk2.3 would crash if too much was put into the field
  29. #Tk3.0 scrolling does not work
  30.  
  31.     global c w
  32.     set w .win
  33.     catch {destroy $w}
  34.     toplevel $w
  35.     set entity test
  36.     wm title $w $entity
  37.     wm iconname $w $entity
  38.     wm minsize $w 100 100
  39.     set c $w.frame2.c
  40.  
  41.     frame $w.frame1 -relief raised -bd 2
  42.     frame $w.frame2 -relief raised -bd 2
  43.     button $w.ok -text "Quit" -command "destroy $w; destroy ."
  44.     pack append $w $w.frame1 {top fill} $w.frame2 {top fill expand} \
  45.             $w.ok {bottom pady 10 frame center}
  46.     
  47.     canvas $c -scrollregion {0c 0c 20c 50c} -width 10c -height 5c
  48.     scrollbar $w.frame2.vscroll  -relief sunken -command "$c yview"
  49.     scrollbar $w.frame2.hscroll -orient horiz -relief sunken \
  50.     -command "$c xview"
  51.     pack append $w.frame2 $w.frame2.hscroll {bottom fillx} \
  52.             $w.frame2.vscroll {right filly} $c {expand fill}
  53.     $c config -xscroll "$w.frame2.hscroll set" \
  54.     -yscroll "$w.frame2.vscroll set"
  55.  
  56.     set attr list
  57.     set ypos .5c
  58.     set ext "_frame"
  59.     set frameName $c.$attr$ext
  60.     frame $frameName
  61.     set cmd [concat $frameName.$attr {yview}]
  62.     set ext "_scroll"
  63.     set scrollName $frameName.$attr$ext
  64.     scrollbar $scrollName -command $cmd -orient vert
  65.  
  66.     set cmd [concat $scrollName {set}]
  67.     text $frameName.$attr -yscroll $cmd -relief sunken \
  68.       -width 18 -height 3 -foreground black -background white
  69.  
  70.     pack append $frameName $scrollName {right filly} \
  71.         $frameName.$attr {left expand fill}
  72.     $c create window 4c $ypos -window $frameName \
  73.          -anchor nw -tags item
  74.  
  75.