home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / tcl / 1279 < prev    next >
Encoding:
Text File  |  1992-08-31  |  2.0 KB  |  72 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!wupost!gumby!destroyer!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!sctc.com!scott
  3. From: scott@sctc.com (Scott Hammond)
  4. Subject: newbie tk question: extra window with 'wish -f'?  && border?
  5. Message-ID: <1992Aug31.163347.25456@sctc.com>
  6. Organization: SCTC
  7. Date: Mon, 31 Aug 1992 16:33:47 GMT
  8. Lines: 62
  9.  
  10. Trying to learn tk based on a demo fragment I've hacked.  
  11. I have two questions:
  12.  
  13. 1.  When I run this, I get two windows, one which wish puts up
  14. automatically, and the one mkIcon puts up.  How do I get rid
  15. of the first one?
  16.  
  17. 2.  Neither window has a border visible on a white background (B&W
  18. display).  How do I make a visible border on the mkIcon's window?
  19.  
  20. The code:
  21.  
  22.  
  23. set auto_path "$tk_library/demos $auto_path"
  24. #wm title . "Widget Demonstration"
  25.  
  26.  
  27. proc mkIcon {{w .icon}} {
  28.     global tk_library
  29.     catch {destroy $w}
  30.     toplevel $w
  31.     dpos $w
  32.     wm title $w "Iconic Button test"
  33.     wm iconname $w "Icons"
  34.     message $w.msg -font -Adobe-times-medium-r-normal--*-180* -aspect 300 \
  35.             -text "This is a test"
  36.     frame $w.frame -borderwidth 10
  37.     pack append $w.frame \
  38.         [button $w.frame.b1 -bitmap @$tk_library/demos/bitmaps/flagdown  \
  39.                 -command "iconCmd $w.frame.b1"] {left expand} \
  40.         [frame $w.frame.right] {left expand}
  41.     button $w.ok -text destroy -command "destroy $w"
  42.  
  43.     pack append $w $w.msg {top frame c} $w.frame {top expand fill} \
  44.             $w.ok {bottom}
  45.  
  46.     return $w.frame.b1
  47. }
  48.  
  49. proc iconCmd {w} {
  50.     global tk_library
  51.     set bitmap [lindex [$w config -bitmap] 4]
  52.     if {$bitmap == "@$tk_library/demos/bitmaps/flagdown"} {
  53.         $w config -bitmap @$tk_library/demos/bitmaps/flagup
  54.     } else {
  55.         $w config -bitmap @$tk_library/demos/bitmaps/flagdown
  56.     }
  57. }
  58.  
  59. # Position a dialog box at a reasonable place on the screen.
  60.  
  61. proc dpos w {
  62.     wm geometry $w +300+300
  63. }
  64.  
  65. set xyz [ mkIcon ]
  66.  
  67. puts stdout $xyz
  68.  
  69.  
  70. --
  71. Scott Hammond (scott@sctc.com)
  72.