tk_messageBox(3tk)
π¬ tk_messageBox β the manual page, but make it make sense π¬
okay bestie, sit down, hydrate, because we're talking about tk_messageBox β a built-in command from the Tk family of built-in commands. It pops up a message window and then justβ¦ waits for you. Iconic behaviour honestly. π«Ά
β¨ NAME β¨
tk_messageBox β pops up a message window and waits for user response.
πΈ SYNOPSIS πΈ
tk_messageBox ?option value ...?
π¦ DESCRIPTION π¦
So here's the vibe. This procedure creates and displays a message window with an application-specified message, an icon, and a set of buttons. Every single button in that message window has its own unique symbolic name β go peek at the -type options if you wanna meet them all. π
Once the message window is popped up, tk_messageBox just sits there waiting for the user to pick a button. No rush. No pressure. Then, and only then, it returns the symbolic name of the selected button. That's the whole personality.
The following option-value pairs are supported:
-commandstring β Specifies the prefix of a Tcl command to invoke when the user closes the dialog. The actual command is made of string followed by a space and the name of the button clicked by the user to close the dialog. β οΈ Heads up: this one is only available on macOS.-defaultname β name gives the symbolic name of the default button for this message window (likeβokβ,βcancelβ, and so on β the quote marks are literally in the docs, we keep the lore). See-typefor a list of the symbolic names. If you don't specify this option, the first button in the dialog becomes the default.-detailstring β Specifies an auxiliary message to go with the main message given by the-messageoption. This detail gets presented beneath the main message and, where the OS supports it, in a less emphasized font than the main message. It's giving "fine print but make it cute" π-iconiconImage β Specifies an icon to display. iconImage must be one of these four and no others:error,info,question,warning. If you don't specify this option, theinfoicon shows up. π-messagestring β Specifies the message to display in this message box. The default value is an empty string.-parentwindow β Makes window the logical parent of the message box. The message box gets displayed on top of its parent window.-titletitleString β Specifies a string to display as the title of the message box. The default value is an empty string.-typepredefinedType β Arranges for a predefined set of buttons to be displayed. The possible values for predefinedType are:abortretryignoreβ Displays three buttons whose symbolic names areabort,retryandignore.okβ Displays one button whose symbolic name isok. This is the default. β¨okcancelβ Displays two buttons whose symbolic names areokandcancel.retrycancelβ Displays two buttons whose symbolic names areretryandcancel.yesnoβ Displays two buttons whose symbolic names areyesandno.yesnocancelβ Displays three buttons whose symbolic names areyes,noandcancel.
π₯ EXAMPLE π₯
no cap, here's the classic "are you SURE you wanna quit" moment:
set answer [tk_messageBox -message "Really quit?" \
-icon question -type yesno \
-detail "Select \"Yes\" to make the application exit"]
switch -- $answer {
yes exit
no {tk_messageBox -message "I know you like this application!" \
-type ok}
}
the no branch is lowkey a whole love letter to your user ππ
π KEYWORDS π
message box
and that's the whole page, bestie β main character energy from start to finish πβ
this was Tk, version 4.2, dated tk_messageBox(3tk), and yes that's the same name twice, we love a consistent icon π bye mwah π π
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms