Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

perl/tk messagebox

by Anonymous Monk
on Dec 17, 2001 at 23:56 UTC ( [id://132638]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

does anyone know how to create a messagebox with perl/tk? i can't find any examples.

Replies are listed 'Best First'.
Re: perl/tk messagebox
by clintp (Curate) on Dec 18, 2001 at 00:07 UTC
    Do you mean like a popup dialog box ("Please reboot now. OK/Cancel") or do you mean like a mouseover message? The former can be done easily with Tk::Dialog.

    Untested:

    use Tk::Dialog; [....] $d=$mw->Dialog(-title => "reboot", -text => "Please reboot now?", -buttons => [ qw/ Yes Cancel / ]); if ($d->Show eq "Yes") { halt(); }
      Dialog will work if you only want to display a text message. If you are looking for a replacement for the VB MsgBox command , you need to use DialogBox.
      use Tk::DialogBox; use Tk::JPEG; [.....] $d = $mw->DialogBox( -title => "reboot", -buttons => [ qw/Yes Cancel/] +); $mw->Photo( "redx", -format => "JPEG", -file => "redx.jpg"); $d->add( Label, image => "redx"); $d->add( Label, -text => "Please reboot now?"); if( $d->Show eq "Yes") { halt(); }
      And for a truly simple example, in which all you want to do is display a message (and a little "OK" box comes up by default to let you flush the message when you are finished reading it), the above can be narrowed down to:
      $d=$tl->Dialog(-title => "A Message", -text => "This is my message."); $d->Show;
(ichimunki) Re: perl/tk messagebox
by ichimunki (Priest) on Dec 18, 2001 at 00:04 UTC
    Try the 'widget' demo included with the Tk module. Lots of good code demos in there. If you mean dialog box, then you might also read 'perldoc Tk::toplevel'. If you mean a message in your existing window, look at 'perldoc Tk::Label'.

    edit On second thought, I like clintp's idea about using Tk::Dialog a lot more than the Tk classes I mentioned.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://132638]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-14 18:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found