Friday, November 24, 2006

[perl] Popup window

#!/usr/bin/perl
# written by vaibhav gupta
use Gtk2 '-init';
$x=100;$y=100; #default Cordinates
$blue = 0xffff ;
$label = "Hello there";
$label = $ARGV[0] if $ARGV[0];
$delay = 5 ;
$delay = $ARGV[1] if $ARGV[1];
$x = $ARGV[2] if $ARGV[2];
$y = $ARGV[3] if $ARGV[3];
$blue = $ARGV[4] if $ARGV[4] ;

sub usages {
        print "\n $ARGV[0] <label> <delay> <x> <y> <color>\n";
}

$window = Gtk2::Window->new("popup");
$window->set_title("Hello");
$window->signal_connect( destroy => sub {Gtk2->main_quit}) ;
$label = Gtk2::Label->new($label);
$label->modify_fg('normal',Gtk2::Gdk::Color->new(0,0,$blue) );
$window->add($label);
$window->move($x,$y);
#$window->resize(300,30);
$window->show_all();
Glib::Idle->add( sub { Gtk2->main_quit; 0 } );
#$window->begin_move_drag(0,100,100,1);
Gtk2->main;
print `sleep $delay`;

3 comments:

Unknown said...

Hello,

I've got a quick question.

I am running Windows 7 in 64 bit mode, and I get an error when I try to run your code.

I have a bit of familiarity with Perl but I am not familiar with what gtk2.pm does.

Could you put a bit of an explanation of your code please?

I'd really appreciate it.

guptav said...

This won't work on windows...
I suggest you to switch to Linux (ubuntu 9.10) ... you will thank me later...


Vaibhav.

cialis said...

Hello, I do not agree with the previous commentator - not so simple