Add a script to clean up after Tcl/Tk installation
[git/jnareb-git.git] / mingw / lib / tk8.5 / demos / msgbox.tcl
blobfb986e198f0a91f0997fed3874c8be8a0d4b3bc9
1 # msgbox.tcl --
3 # This demonstration script creates message boxes of various type
5 # RCS: @(#) $Id: msgbox.tcl,v 1.6 2007/12/13 15:27:07 dgp Exp $
7 if {![info exists widgetDemo]} {
8 error "This script should be run from the \"widget\" demo."
11 package require Tk
12 package require Ttk
14 set w .msgbox
15 catch {destroy $w}
16 toplevel $w
17 wm title $w "Message Box Demonstration"
18 wm iconname $w "messagebox"
19 positionWindow $w
21 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."
22 pack $w.msg -side top
24 pack [addSeeDismiss $w.buttons $w {} {
25 ttk::button $w.buttons.vars -text "Message Box" -command "showMessageBox $w"
26 }] -side bottom -fill x
27 #pack $w.buttons.dismiss $w.buttons.code $w.buttons.vars -side left -expand 1
29 frame $w.left
30 frame $w.right
31 pack $w.left $w.right -side left -expand yes -fill y -pady .5c -padx .5c
33 label $w.left.label -text "Icon"
34 frame $w.left.sep -relief ridge -bd 1 -height 2
35 pack $w.left.label -side top
36 pack $w.left.sep -side top -fill x -expand no
38 set msgboxIcon info
39 foreach i {error info question warning} {
40 radiobutton $w.left.b$i -text $i -variable msgboxIcon \
41 -relief flat -value $i -width 16 -anchor w
42 pack $w.left.b$i -side top -pady 2 -anchor w -fill x
45 label $w.right.label -text "Type"
46 frame $w.right.sep -relief ridge -bd 1 -height 2
47 pack $w.right.label -side top
48 pack $w.right.sep -side top -fill x -expand no
50 set msgboxType ok
51 foreach t {abortretryignore ok okcancel retrycancel yesno yesnocancel} {
52 radiobutton $w.right.$t -text $t -variable msgboxType \
53 -relief flat -value $t -width 16 -anchor w
54 pack $w.right.$t -side top -pady 2 -anchor w -fill x
57 proc showMessageBox {w} {
58 global msgboxIcon msgboxType
59 set button [tk_messageBox -icon $msgboxIcon -type $msgboxType \
60 -title Message -parent $w\
61 -message "This is a \"$msgboxType\" type messagebox with the \"$msgboxIcon\" icon"]
63 tk_messageBox -icon info -message "You have selected \"$button\"" -type ok\
64 -parent $w