NAME

ttk::dialog -
create a dialog box

SYNOPSIS

package require ttk::dialog ?0.8?

ttk::dialog pathname ?options...?
ttk::dialog::define dialogType ?options...?

DESCRIPTION

A dialog box is a transient top-level window containing an icon, a short message, an optional, longer, detail message, and a row of command buttons. When the user presses any of the buttons, a callback function is invoked and then the dialog is destroyed.

Additional widgets may be added in the dialog client frame.

OPTIONS

NameDatabase nameDatabase class
-titlen/an/a
 Specifies a string to use as the window manager title.
-messagen/an/a
 Specifies the message to display in this dialog.
-detailn/an/a
 Specifies a longer auxiliary message.
-commandn/an/a
 Specifies a command prefix to be invoked when the user presses one of the command buttons. The symbolic name of the button is passed as an additional argument to the command. The dialog is dismissed after invoking the command.
-parentn/an/a
 Specifies a toplevel window for which the dialog is transient. If omitted, the default is the nearest ancestor toplevel. If set to the empty string, the dialog will not be a transient window.
-typen/an/a
 Specifies a built-in or user-defined dialog type. See PREDEFINED DIALOG TYPES, below.
-iconn/an/a
 Specifies one of the stock dialog icons, info, question, warning, error, auth, or busy. If set to the empty string (the default), no icon is displayed.
-buttonsn/an/a
 A list of symbolic button names.
-labelsn/an/a
 A dictionary mapping symbolic button names to textual labels. May be omitted if all the buttons are predefined.
-defaultn/an/a
 The symbolic name of the default button.
-canceln/an/a
 The symbolic name of the "cancel" button. The cancel button is invoked if the user presses the Escape key and when the dialog is closed from the window manager. If -cancel is not specified, the dialog ignores window manager close commands (WM_DELETE_WINDOW).

WIDGET COMMANDS

ttk::dialog::clientframe dlg
Returns the widget path of the client frame. Other widgets may be added to the client frame. The client frame appears between the detail message and the command buttons.

PREDEFINED DIALOG TYPES

The -type option, if present, specifies default values for other options. ttk::dialog::define type options... specifies a new stock dialog type. The following stock dialog types are predefined:

ttk::dialog::define ok \
    -icon info -buttons {ok} -default ok
ttk::dialog::define okcancel \
    -icon info -buttons {ok cancel} -default ok -cancel cancel
ttk::dialog::define yesno \
    -icon question -buttons {yes no}
ttk::dialog::define yesnocancel \
    -icon question -buttons {yes no cancel} -cancel cancel
ttk::dialog::define retrycancel \
    -icon question -buttons {retry cancel} -cancel cancel

STOCK BUTTONS

The following ``stock'' symbolic button names have predefined labels: yes, no, ok, cancel, and retry.

It is not necessary to list these in the -labels dictionary.

EXAMPLE

proc saveFileComplete {button} {
    switch -- $button {
    	yes { # save file ... }
	no  { exit }
	cancel { # no-op }
    }
}

ttk::dialog .saveFileDialog \
    -title "Save file?" \
    -icon question \
    -message "Save file before closing?" \
    -detail "If you do not save the file, your work will be lost" \
    -buttons [list yes no cancel] \ 
    -labels [list yes "Save file" no "Don't save"] \
    -command saveFileComplete \
    ;

SEE ALSO

tk_messageBox(n), wm(n), toplevel(n)