ttk::dialog(3) create a dialog box


package require ttk::dialog ?0.8?
ttk::dialog pathname ?options...? ttk::dialog::define dialogType ?options...?


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.


[ -title n/a n/a ] Specifies a string to use as the window manager title. [ -message n/a n/a ] Specifies the message to display in this dialog. [ -detail n/a n/a ] Specifies a longer auxiliary message. [ -command n/a 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. [ -parent n/a 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 window. [ -type n/a n/a ] Specifies a built-in or user-defined dialog type. See PREDEFINED DIALOG TYPES, below. [ -icon n/a n/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. [ -buttons n/a n/a ] A list of symbolic button names. [ -labels n/a n/a ] A dictionary mapping symbolic button names to textual labels. May be omitted if all the buttons are predefined. [ -default n/a n/a ] The symbolic name of the default button. [ -cancel n/a 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_WINDOW).


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.


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


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.


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 \