Tile dialog Table of Contents

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 com-mand 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

Command-Line Name:-title
Database Name: n/a
Database Class: n/a

Specifies a string to use as the window manager title.

Command-Line Name:-message
Database Name: n/a
Database Class: n/a

Specifies the message to display in this dialog.

Command-Line Name:-detail
Database Name: n/a
Database Class: n/a

Specifies a longer auxiliary message.

Command-Line Name:-command
Database Name: n/a
Database Class: n/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.

Command-Line Name:-parent
Database Name: n/a
Database Class: n/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 win-dow.

Command-Line Name:-type
Database Name: n/a
Database Class: n/a

Specifies a built-in or user-defined dialog type. See PREDE-FINED DIALOG TYPES, below.

Command-Line Name:-icon
Database Name: n/a
Database Class: n/a

Specifies one of the stock dialog icons, info, question, warn-ing, error, auth, or busy. If set to the empty string (the default), no icon is displayed.

Command-Line Name:-buttons
Database Name: n/a
Database Class: n/a

A list of symbolic button names.

Command-Line Name:-labels
Database Name: n/a
Database Class: n/a

A dictionary mapping symbolic button names to textual labels. May be omitted if all the buttons are predefined.

Command-Line Name:-default
Database Name: n/a
Database Class: n/a

The symbolic name of the default button.

Command-Line Name:-cancel
Database Name: n/a
Database Class: n/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_WIN-DOW).

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)

tile 0.8 dialog(n)


Table of Contents