home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!rpi!gatech!cae!cae!usenet
- From: estephen@whosnext.cad.gatech.edu (Eric R Stephens)
- Newsgroups: comp.lang.tcl
- Subject: canvas and scrolling text field
- Date: 11 Jan 1993 13:59:36 GMT
- Organization: Georgia Institute of Technology, CAE/CAD Lab
- Lines: 63
- Message-ID: <1irug8INN8d6@cae.cad.gatech.edu>
- NNTP-Posting-Host: whosnext.cad.gatech.edu
- Keywords: wish, canvas, scrolling field
-
- I'm trying to impliment a scrolling text field within a scrolling
- canvas ($c). I'm define a frame ($c.$name_frame) with a text
- ($c.$name_frame.$name) and a scroll ($c.$name_frame.scroll). I then
- create a window widget inside the canvas.
- This all seems to work find until I enter or insert more text
- than can be shown (about 1 line more) and then tvtwm crashes. Any
- ideas?
-
- 3.0: Does not crash but also does not respond to yview.
-
- #Sorry about the cut up looking code.
-
- #create a toplevel window .win
- #.win contains a canvas, two scrolls, and a quit button
- #.win.frame2.c contains a frame acting as a scrollable text field
-
- #Tk2.3 would crash if too much was put into the field
- #Tk3.0 scrolling does not work
-
- global c w
- set w .win
- catch {destroy $w}
- toplevel $w
- set entity test
- wm title $w $entity
- wm iconname $w $entity
- wm minsize $w 100 100
- set c $w.frame2.c
-
- frame $w.frame1 -relief raised -bd 2
- frame $w.frame2 -relief raised -bd 2
- button $w.ok -text "Quit" -command "destroy $w; destroy ."
- pack append $w $w.frame1 {top fill} $w.frame2 {top fill expand} \
- $w.ok {bottom pady 10 frame center}
-
- canvas $c -scrollregion {0c 0c 20c 50c} -width 10c -height 5c
- scrollbar $w.frame2.vscroll -relief sunken -command "$c yview"
- scrollbar $w.frame2.hscroll -orient horiz -relief sunken \
- -command "$c xview"
- pack append $w.frame2 $w.frame2.hscroll {bottom fillx} \
- $w.frame2.vscroll {right filly} $c {expand fill}
- $c config -xscroll "$w.frame2.hscroll set" \
- -yscroll "$w.frame2.vscroll set"
-
- set attr list
- set ypos .5c
- set ext "_frame"
- set frameName $c.$attr$ext
- frame $frameName
- set cmd [concat $frameName.$attr {yview}]
- set ext "_scroll"
- set scrollName $frameName.$attr$ext
- scrollbar $scrollName -command $cmd -orient vert
-
- set cmd [concat $scrollName {set}]
- text $frameName.$attr -yscroll $cmd -relief sunken \
- -width 18 -height 3 -foreground black -background white
-
- pack append $frameName $scrollName {right filly} \
- $frameName.$attr {left expand fill}
- $c create window 4c $ypos -window $frameName \
- -anchor nw -tags item
-
-