[5] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

Re: anyone here yet?

daemon@ATHENA.MIT.EDU (Shawn T Amundson)
Thu May 1 23:17:07 1997

From: Shawn T Amundson <amundson@cs.umn.edu>
To: gtk-list@redhat.com
Date: Thu, 1 May 1997 22:16:24 -0500 (CDT)
In-Reply-To: <lzsp06eqp1.fsf@huygens.cit.cornell.edu> from "Owen Taylor" at May 1, 97 07:08:09 pm
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com

Words Of Owen Taylor:
>
>-------
>#!/usr/bin/perl -w
>
>use Gtk;
>
>Gtk::init ($0,\@ARGV);
>
>my $window = Gtk::window('toplevel');
>$window->connect("destroy", sub { Gtk::exit(0) });
>$window->border_width(10);
>
>my $button = Gtk::button_with_label("Hello World");
>$button->connect("clicked", sub { print "Hello World\n"; Gtk:exit(0) });
>$window->add($button);
>
>$button->show;
>$window->show;
>
>Gtk::main();
>

Personally, I prefer the following for perl.  Also, PerlTk is an awesome 
example of how to use the OO features of perl to their fullest.

--
use Gtk;

GtkInit($0,\@ARGV);                 # Export because the code is easier
my $window = GtkWindow('toplevel'); # to read.  Export only when it is the
                                    # right thing to do.  It is the right
                                    # thing here.

$window->connect("destroy", sub { GtkExit(0) };

# The next includes the "add" right along with the 
# with, defining the parent right away, making use of
# the OO design a bit more. (This causes significant
# decrease in code.) 
$button = $window->button_with_label("Hello World");

# Perhaps too, $button->reparent($newparent) a valid routine.

$button->show;
$window->show;

GtkMain();


--
Shawn T. Amundson		University of Minnesota
Systems Administration	 	Computer Science System Staff
amundson@cs.umn.edu	  	http://www.cs.umn.edu/~amundson/     	

Count your friends, it won't take long; including yourself, you'll
find you only have one; you better have fun. -- Cathrine

--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post