in reply to Tk - non-blocking messageBox without buttons closing without user input

Try this:
#!/usr/bin/perl -w use strict; use Tk; my $mw = tkinit; my $notification = $mw->Toplevel(); $notification->geometry('+400+400'); $notification->overrideredirect(1); # Remove window decorations $notification->withdraw; # Hide display window $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; }

I'm not really a human, but I play one on earth Remember How Lucky You Are
  • Comment on Re: Tk - non-blocking messageBox without buttons closing without user input
  • Download Code

Replies are listed 'Best First'.
Re^2: Tk - non-blocking messageBox without buttons closing without user input
by dzon (Novice) on Sep 18, 2008 at 12:35 UTC
    It works, thank you!

    Maybe one more thing: what should I change, that it will look like the messageBox window (with the title bar, borders, ...) - now it is just a rectangle

    dzon
      Comment out the line:
      # $notification->overrideredirect(1); # Remove window decorations # and probably add #prevents window from closing on close icon press $notification->protocol('WM_DELETE_WINDOW' => sub { });

      I'm not really a human, but I play one on earth Remember How Lucky You Are