The tk_messageBox
command displays a message window with a defined message, an icon and a collection of command buttons and waits on the user's response. The return value provided is the symbolic value (see the type
option in the following table) assigned to the button selected.
The syntax is as follows:
tk_messageBox option value …
The tk_messageBox
command accepts one or more option value
pairs as detailed below. If no option value pairs are provided the command will display an empty window with an OK button.
Option |
Interpretation |
---|---|
|
Designates which button is the default. |
|
Displays a secondary message to the message provided by the –message option. |
|
Sets the icon to display, based on the value referenced by name. Acceptable values are: error, info (default), question, or warning. |
|
Sets the message to be displayed |
|
Specifies the parent of the dialog. The dialog is displayed on top of the parent. |
|
Sets the text to be displayed in the dialog title bar. |
|
Specifies the button set to be utilized by the dialog. Acceptable values are: abortretryignore: Displays three buttons with the symbolic names abort, retry, and ignore. ok: Displays a single button with the symbolic name ok. okcancel: Displays two buttons with the symbolic names ok and cancel. retrycancel: Displays two buttons with the symbolic names retry and cancel. yesno: Displays two buttons with the symbolic names yes and no. yesnocancel: Displays three buttons with the symbolic names yes, no, and cancel. |
In the following example, we will display a message box and assign the return value to a named variable. Enter the following commands:
1 % set response [tk_messageBox -message "Confirm Exit" -icon question -
type okcancel -detail "Please select "OK" to exit"
You should now see the following dialog displayed.
Note that in your shell window, the input line is no longer active and if this dialog were being displayed from an application, we could no longer interact with any other widgets in the same application. This is due to the fact that the application (in this case, the wish shell) is awaiting a response. Click on the OK button and you will notice that the symbolic value of ok
is displayed on the command line and you can now interact with your shell. Enter the following command to confirm that the symbolic value was assigned to the named variable:
2 % puts $response
ok
52.14.134.130