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

Dear all,
I am new to the perl T/k
I just wanted to display an information in a box at the notification area
or can be at any where in the screen
my perl program is a daemon please give me some ideas

  • Comment on display information in the box in a notification area

Replies are listed 'Best First'.
Re: display information in the box in a notification area
by zentara (Cardinal) on Dec 22, 2009 at 13:28 UTC
    .....any where on screen?.....try this for Tk
    #!/usr/bin/perl -w use strict; use Tk; my $mw = tkinit; my $notification = $mw->Toplevel(); $notification->geometry('+400+400'); $notification->withdraw; # Hide display window $notification->protocol('WM_DELETE_WINDOW' => sub { }); #$notification->overrideredirect(1); # Remove window decorations $notification->Label( -text => 'Your message displayed here.', -foreground => 'white', -background => 'black', -height => 5 )->pack; $mw->Button( -text => 'Display Notification Window', -command => \&display_note )->pack; MainLoop; sub display_note { $notification->deiconify; $notification->raise; # this is where you setup a condition to withdraw it $notification->after( 5000, \&hide_note ); } sub hide_note { $notification->withdraw; }
    .... if you can use Gtk2, see Gtk2::StatusIcon Demo

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku

      Yeah that is really cool
      but is it possible to remove the minimize and maximize button in the dialog box ?

        ... yes....uncomment the line
        # $notification->overrideredirect(1); # Remove window decorations

        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku
Re: display information in the notification area
by mykl (Monk) on Dec 22, 2009 at 13:11 UTC

    Being a cross-platform toolkit, I don't think Tk provides any way to put things in the notification area in Windows.

    You could use Tk::Dialog to create a window which has your information in it, and an 'OK' button. Would that fit your needs?

    --

    "Any sufficiently analyzed magic is indistinguishable from science" - Agatha Heterodyne

Re: display information in the box in a notification area
by llancet (Friar) on Dec 22, 2009 at 13:58 UTC
    only on Xnix:
    system "xmessage your message";
    for more detailed options, see man xmessage