home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / tcl_447.lzh / TCL / tcl.lzh / tcl / tclprocs / hello.tcl < prev    next >
Text File  |  1990-05-03  |  780b  |  33 lines

  1. # this only works if run as a top-level procedure
  2.  
  3. global hellowin message width height
  4. set hellowin [window open 300 50 300 50 Hello]
  5.  
  6. if {[string compare $argv ""] != 0} {
  7.     set userfont [font open $argv]
  8.     display font $userfont
  9. }
  10.  
  11. set message "Hello, world."
  12. set width [display textwidth $message]
  13. set height [display fontheight]
  14.  
  15. proc repaint_window {} {
  16.     global hellowin width height message
  17.     window current $hellowin
  18.     window blank $hellowin
  19.     display move [expr {([window width $hellowin] - $width) / 2}] [expr {([window height $hellowin] + $height/2) / 2}]
  20.     display text $message
  21. }
  22.  
  23. proc close_window {} {
  24.     global hellowin
  25.     window close $hellowin
  26.     endeventloop
  27. }
  28.  
  29. repaint_window
  30. windowevent attach newsize repaint_window
  31. windowevent attach closewindow close_window
  32. eventloop
  33.