ztk::toast
Shows a short message at the bottom of the main window for a time.
Synopsis
ztk::toast TEXT ?-duration MS?
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
TEXT |
text | The message. | |
-duration |
milliseconds | 2500 | The time that the message stays, after it slides in and before it slides out. |
The message is a label with the style class toast, placed at the bottom center of .. It slides in and out in 220 ms. With ztk::animate reduce 1, it shows and goes at once. The label goes away at the end.
Return value
The path of the label of the message, such as .__ztk_toast1.
Errors
| Error | When |
|---|---|
expected integer but got "X" |
-duration is no integer. |
value for "-duration" missing |
-duration with no value. |
bad option "-X" |
An unknown option. -duration is the only option. |
wrong # args: should be "ztk::toast text ?arg ...?" |
No text. |
Platforms
| Platform | Works |
|---|---|
| Windows | Yes |
| macOS | Yes |
| Linux, Wayland | Yes |
| Linux, X11 | Yes |
| Web | Yes. A WebAssembly app of ztk::wasm::run has no ztk::toast. |
| iOS, Android | Yes |
| Headless | Yes |
Example
button .save -text Save -command {ztk::toast "Saved" -duration 1500}
pack .save -padx 20 -pady 20
.save invoke