Re: Gtk2->init(\ ARGV);



On Wed, 2004-01-14 at 14:35, muppet wrote:
On Tuesday, January 13, 2004, at 08:02 PM, Andrew Cutler wrote:

I've just started playing with GTK and some of the example code uses
Gtk2->init(\ ARGV);

you've either fetched a really old gtk2-perl (<0.20) or you've found  
buggy examples.  where was the example code?
The example was:
http://cvs.sourceforge.net/viewcvs.py/gtk2-perl/gtk2-perl/tutorial-examples/progressbar.pl

I just went back to have a look and the 5 or 6 scripts I randomly
selected all use it.

I guess they must be using old deprecated methods. It explains the weird
looking:

my $pdata = {};
$pdata->{WINDOW} = Gtk2::Window->new('toplevel');
$pdata->{WINDOW}->resizable(TRUE);

and why when I tried Gtk2->init; I got:

Can't locate object method "resizable" via package "Gtk2::Window"




Can someone please explain what the arguments are supposed to be and
what it does compared to use GTK2 -init; ?

Gtk2->init this is the perl version of gtk_init().  it is bound as a  
class static method for Gtk2, since it modifies the internal state of  
the gtk+ library.[1]  the perl wrapper is smart enough to find and  
modify @ARGV for itself, so you pass no arguments to it.

reference docs for gtk_init()
    http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-init

reference docs for Gtk2->init
     
http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/
main.html#boolean_Gtk2_init

since 95% of the time you want Gtk2 initialized in your main program,  
Gtk2 offers an import argument, "-init", which calls Gtk2->init for you.

   use Gtk2 -init;

is equivalent to

   use Gtk2;
   Gtk2->init;



[1] or because it's "object-oriented", in the buzzword-sense of the  
term.  see the methods versus functions thread for more philosophy on  
that.


Thanks for the help.

Cheers,


Andrew

Too much procrastination will make you blind. -- Me. August 2000.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]