#!/usr/bin/perl use warnings; use Tk; use strict; my $main = new MainWindow; $main->geometry('200x200'); $main->Button(-text=>"click",-command=>sub{ print "Button left click\n"; })->pack; $main->bind('', \&some_sub); MainLoop; sub some_sub{ print "@_\n"; my $widget = shift; my $x = $widget->pointerx; my $y = $widget->pointery; my $mw_bdw = 2; #mainwindow border width ### Create a Mainwindow ### my $top = new MainWindow(-borderwidth=>$mw_bdw, -relief=>'ridge', -bg => "#0000FF"); $top->geometry("150x100+$x+$y"); # displaying at top left on any resolution $top->overrideredirect(1); # Remove window decorations and keep on all screens ### create a text widget ### my $imstr = "THIS IS A TEST NOTIFICTION LONG ENOUGH TO WRAP"; my $TEXT = $top->Text( -foreground=> 'white', -background=> '#0000FF', -wrap => 'word', -height => 7, -width => 50)->pack; $TEXT->insert('end', "$imstr", ); #$top-> after(5000, \&exitprg); # autoclose in 5000 milisecs $top->bind('',sub{$top->destroy}); #or sub exitprg MainLoop; #### FUNCTIONS #### sub exitprg { my $top = shift; print STDERR "CALLED EXIT\n"; $top-> destroy; # to kill the window and exit from prog } }