Balloon.tcl 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: Balloon.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
  4. #
  5. # Tix Demostration Program
  6. #
  7. # This sample program is structured in such a way so that it can be
  8. # executed from the Tix demo program "widget": it must have a
  9. # procedure called "RunSample". It should also have the "if" statment
  10. # at the end of this file so that it can be run as a standalone
  11. # program using tixwish.
  12. # This file demonstrates the use of the tixBalloon widget, which provides
  13. # a interesting way to give help tips about elements in your user interface.
  14. # Your can display the help message in a "balloon" and a status bar widget.
  15. #
  16. proc RunSample {w} {
  17. # Create the status bar widget
  18. #
  19. label $w.status -width 40 -relief sunken -bd 1
  20. pack $w.status -side bottom -fill y -padx 2 -pady 1
  21. # These are two a mysterious widgets that need some explanation
  22. #
  23. button $w.button1 -text " Something Unexpected " \
  24. -command "destroy $w"
  25. button $w.button2 -text " Something Else Unexpected " \
  26. -command "destroy $w.button2"
  27. pack $w.button1 $w.button2 -side top -expand yes
  28. # Create the balloon widget and associate it with the widgets that we want
  29. # to provide tips for:
  30. tixBalloon $w.b -statusbar $w.status
  31. $w.b bind $w.button1 -balloonmsg "Close window" \
  32. -statusmsg "Press this button to close this window"
  33. $w.b bind $w.button2 -balloonmsg "Self-destruct\nButton" \
  34. -statusmsg "Press this button and it will get rid of itself"
  35. }
  36. if {![info exists tix_demo_running]} {
  37. wm withdraw .
  38. set w .demo
  39. toplevel $w; wm transient $w ""
  40. RunSample $w
  41. bind $w <Destroy> {if {"%W" == ".demo"} exit}
  42. }