home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / tcl / 1211 < prev    next >
Encoding:
Text File  |  1992-08-17  |  1.6 KB  |  54 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!wupost!cs.utexas.edu!tamsun.tamu.edu!inetg1!cgp
  3. From: cgp@Arco.COM (Chris Phillips  (214) 754-6419)
  4. Subject: canvas problem
  5. Message-ID: <1992Aug18.023804.25826@Arco.COM>
  6. Organization: ARCO Oil and Gas Company
  7. Date: Tue, 18 Aug 1992 02:38:04 GMT
  8. Lines: 44
  9.  
  10. For some reason the following script doesn't give the expected results.
  11. It creates two canvases: one horizontal and one vertical.  They should
  12. each create 10 squares, all in a row.  The horizontal canvas is ok, but
  13. only 2 squares show up in the vertical canvas.
  14.  
  15.  
  16. #!/usr/local/bin/wish -f
  17.  
  18. proc trash {w doy} {
  19.         toplevel $w
  20.         if {$doy == 1} {
  21.                 canvas $w.c -width 1c -height 10c
  22.                 $w.c create rectangle 0 0 1c 10c -fill red
  23.                 for {set j 1} {$j <= 10} {incr j} {
  24.                         $w.c create rectangle \
  25.                           0 [expr $j-1]c 1c ${j}c \
  26.                           -outline black -fill blue
  27.                 }
  28.         } else {
  29.                 canvas $w.c -width 10c -height 1c
  30.                 $w.c create rectangle 0 0 10c 1c -fill red
  31.                 for {set i 1} {$i <= 10} {incr i} {
  32.                         $w.c create rectangle \
  33.                           [expr $i-1]c 0 ${i}c 1c \
  34.                           -outline black -fill blue
  35.                 }
  36.         }
  37.  
  38.         pack append $w $w.c {expand fill}
  39. }
  40.  
  41. trash .t0 0
  42. trash .t1 1
  43. message .m -text "Horizontal: 10 blue squares\nVertical: 2 blue squares" \
  44.   -aspect 1500 -justify center
  45. pack append . .m {expand fill}
  46.  
  47.  
  48. ----- End script -----
  49.  
  50.  
  51. Any ideas?
  52.  
  53. Chris
  54.