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

Hi monks,

I just did a mail alert program. When a new mail arrives the program will alert the user with the help of TK messageBox.

But while displaying the alert, the MainWindow is also there, back to the message box. I don't want that MainWindow to be displayed.

Is there any way to display messagebox without the MainWindow in Tk?


--Lakshmanan G.

Your Attempt May Fail, But Never Fail To Make An Attempt

Replies are listed 'Best First'.
Re: TK mainwindow
by GrandFather (Saint) on Mar 14, 2009 at 05:15 UTC

    Show us sample code that demonstrates the problem then we can provide a solution appropriate to your context. However, the following may be of some help:

    use strict; use warnings; use Tk; use Tk::DialogBox; my $main = MainWindow->new (); my $dlg = $main->DialogBox ( -title => "demo Dialog", -buttons => ["OK"] ); $dlg->add ('Label', -text => <<MSG)->form (); Click OK to close the dialog. MSG $main->withdraw (); $dlg->transient (undef); $dlg->Show (-global);

    True laziness is hard work
Re: TK mainwindow
by lakshmananindia (Chaplain) on Mar 14, 2009 at 05:36 UTC

    Problem solved as follows

    use Tk; my $mw = new MainWindow; $mw->withdraw(); my $response = $mw->messageBox(-icon => 'info', -message => "Testing" +, -title => "Perlmonks" , -type => 'ok');

    Thanks GrandFather for pointing the withdraw function.

    --Lakshmanan G.

    Your Attempt May Fail, But Never Fail To Make An Attempt