tk_messageBox(3tk)

πŸ“¦
version 9.0.4 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’¬ 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:

  • -command string β€” 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.
  • -default name β€” 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 -type for a list of the symbolic names. If you don't specify this option, the first button in the dialog becomes the default.
  • -detail string β€” Specifies an auxiliary message to go with the main message given by the -message option. 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" πŸ’…
  • -icon iconImage β€” 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, the info icon shows up. πŸ“
  • -message string β€” Specifies the message to display in this message box. The default value is an empty string.
  • -parent window β€” Makes window the logical parent of the message box. The message box gets displayed on top of its parent window.
  • -title titleString β€” Specifies a string to display as the title of the message box. The default value is an empty string.
  • -type predefinedType β€” Arranges for a predefined set of buttons to be displayed. The possible values for predefinedType are:
    • abortretryignore β€” Displays three buttons whose symbolic names are abort, retry and ignore.
    • ok β€” Displays one button whose symbolic name is ok. This is the default. ✨
    • okcancel β€” Displays two buttons whose symbolic names are ok and cancel.
    • retrycancel β€” Displays two buttons whose symbolic names are retry and cancel.
    • yesno β€” Displays two buttons whose symbolic names are yes and no.
    • yesnocancel β€” Displays three buttons whose symbolic names are yes, no and cancel.

πŸ”₯ 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