home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tk42r2x.zip / TclTk / lib / tk4.2 / demos / msgbox.tcl < prev    next >
Text File  |  1999-07-27  |  2KB  |  62 lines

  1. # msgbox.tcl --
  2. #
  3. # This demonstration script creates message boxes of various type
  4. #
  5. # SCCS: @(#) msgbox.tcl 1.2 96/08/27 14:42:23
  6.  
  7. set w .msgbox
  8. catch {destroy $w}
  9. toplevel $w
  10. wm title $w "Message Box Demonstration"
  11. wm iconname $w "messagebox"
  12. positionWindow $w
  13.  
  14. label $w.msg -font $font -wraplength 4i -justify left -text "Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box."
  15. pack $w.msg -side top
  16.  
  17. frame $w.buttons
  18. pack $w.buttons -side bottom -fill x -pady 2m
  19. button $w.buttons.dismiss -text Dismiss -command "destroy $w"
  20. button $w.buttons.code -text "See Code" -command "showCode $w"
  21. button $w.buttons.vars -text "Message Box"  \
  22.     -command "showMessageBox $w"
  23. pack $w.buttons.dismiss $w.buttons.code $w.buttons.vars -side left -expand 1
  24.  
  25. frame $w.left 
  26. frame $w.right
  27. pack $w.left $w.right -side left -expand yes -fill y  -pady .5c -padx .5c
  28.  
  29. label $w.left.label -text "Icon"
  30. frame $w.left.sep -relief ridge -bd 1 -height 2
  31. pack $w.left.label -side top
  32. pack $w.left.sep -side top -fill x -expand no
  33.  
  34. set msgboxIcon info
  35. foreach i {error info question warning} {
  36.     radiobutton $w.left.b$i -text $i -variable msgboxIcon \
  37.     -relief flat -value $i -width 16 -anchor w
  38.     pack $w.left.b$i  -side top -pady 2 -anchor w -fill x
  39. }
  40.  
  41. label $w.right.label -text "Type"
  42. frame $w.right.sep -relief ridge -bd 1 -height 2
  43. pack $w.right.label -side top
  44. pack $w.right.sep -side top -fill x -expand no
  45.  
  46. set msgboxType ok
  47. foreach t {abortretryignore ok okcancel retrycancel yesno yesnocancel} {
  48.     radiobutton $w.right.$t -text $t -variable msgboxType \
  49.     -relief flat -value $t -width 16 -anchor w
  50.     pack $w.right.$t -side top -pady 2 -anchor w -fill x
  51. }
  52.  
  53. proc showMessageBox {w} {
  54.     global msgboxIcon msgboxType
  55.     set button [tk_messageBox -icon $msgboxIcon -type $msgboxType \
  56.     -title Message -parent $w\
  57.     -message "This is a \"$msgboxType\" type messagebox with the \"$msgboxIcon\" icon"]
  58.     
  59.     tk_messageBox -icon info -message "You have selected \"$button\"" -type ok\
  60.     -parent $w
  61. }
  62.