messageBox(3pm)
π messageBox(3pm) β Tk::messageBox π
okay bestie, pull up a chair because this one is a Perl page from the User Contributed Perl Documentation pile, and it's genuinely so useful. It's Tk::messageBox, and no cap, it's the little pop-up queen of your Tk era. π
β¨ NAME β¨
Tk::messageBox</purgle> β pop up a message window and wait for user response. That's it, that's the whole job. Iconic behaviour honestly. π«Ά
πΈ SYNOPSIS πΈ
$response = $widget->messageBox(-option => value, ... );
literally one line and you're popping dialogs like it's nothing. π
π¦ DESCRIPTION π¦
So here's the tea: this method uses Tk::Dialog to quickly create several common dialog boxes. A dialog widget consists of a message, an icon and a set of buttons (peep the -type option for that last one π).
After the message window is popped up, messageBox waits for the user to select one of the buttons, and then it returns the button text. And bestie, pls pls pls β check that returned value in a case insensitive manner. Don't be out here doing case-sensitive string compares on user-facing button labels, that's not the vibe. π
β οΈ NOTE: unlikeTk::Dialog, which creates its widget once and can be used many times, themessageBoxwindow is created every single time it's used. Every time. Fresh widget, fresh energy, no reuse. π
The following option/value pairs are supported:
-defaultβ the case-sensitive symbolic name of the default button for this message window ('Ok','Cancel'and so on). Slide over to-typefor the list of symbolic names. If the message box has just one button, it will automatically be made the default. Otherwise, if this option is not specified, there won't be any default button. So like... choose, or accept the void. π³οΈ-iconβ specifies an icon to display. On X11, any of the builtin Tk bitmaps can be specified. On Windows, onlyerror,info,questionorwarningare supported. Windows said "we have four icons and that's the whole menu, bestie." π-messageβ specifies the message to display. The main character of the whole operation ngl. π-titleβ specifies a string to display as the title. Give your window a name, it deserves one. β¨-typeβ specifies a predefined set of buttons to be displayed. The following values are possible:'AbortRetryIgnore','Ok','OkCancel','RetryCancel','YesNo'or'YesNoCancel'. Pick your fighter. π₯
π EXAMPLE π
$response = $mw->messageBox(-icon => 'question', -message => 'Hello
World!', -title => 'My title', -type => 'AbortRetryIgnore', -default =>
'Retry');
see how the options just stack up? icon, message, title, type, default β all the little lewks in one call. Slay. π
π AUTHOR π
Stephen.O.Lidie@Lehigh.EDU. 98/05/25
shoutout to Stephen, dropping this on 98/05/25 and feeding the whole Perl community fr fr. π«Ά
and that's the whole page bestie, no crumbs left β this was messageBox(3pm) from perl v5.40.1, dated 2025-04-13. Go pop a dialog and make it cute. πβ¨π¦
π¦ where this page comes from
- debian trixie: perl-tk 1:804.036+dfsg1-5
- ubuntu questing: perl-tk 1:804.036+dfsg1-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms