Dialogs
Live: the playground runs the example below.
The dialogs and ztk::toast
frame .banner
label .banner.l -text "Your changes are not saved."
pack .banner.l -anchor w
ztk::class .banner add banner
button .ask -text "Message box" -command {
set r [tk_messageBox -message "Save the changes?" -detail "The changes are lost when you close the window." -type yesnocancel -icon question]
ztk::toast "You chose $r"
}
button .color -text "Color" -command {
set c [tk_chooseColor -initialcolor #2563eb]
if {$c ne ""} { .banner configure -background $c }
}
pack .banner -fill x -padx 12 -pady 12
pack .ask .color -side left -anchor n -padx {12 0}

tk_messageBoxhas the options, the types, the icons, and the results ofmessageBox.n. Return invokes the button with the focus, and Escape givescancel, orno,abort, orokwhen the type has no cancel button. On Windows it is the message box of the system.tk_dialoggives the number of the button, or -1 when the window closes.tk_chooseColorhas a grid of swatches, sliders for red, green, and blue, and a hex field. It gives a color such as#2563eb, or an empty string for a cancel. On Windows it is the color dialog of the system.tk_getOpenFile,tk_getSaveFile, andtk_chooseDirectorylist the folders and the files, with the filters of-filetypes. They need the file capability of the program. On Windows and macOS they are the dialogs of the system. On Wayland they are the file chooser of the desktop portal when the session bus hasorg.freedesktop.portal.Desktop, and else the dialogs that ztk draws.- Each dialog is a toplevel of the class
Dialogwith a grab, and it fades in. ztk::toast text ?-duration ms?shows a short message at the bottom of the window. It slides in, stays for 2,500 ms by default, and slides out. The style classbannergives a frame the look of a message in the page.