http://qs321.pair.com?node_id=314551

eoin has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, I recently read the Perl News article about GTK2 and decided to look into it as I have alwats thought that Tk just didn't look good enough. I went to the GTK2 Win Bin home page and downloaded and installed all the dependecies and file nessicary.
I also found the following code to use as an example
#!/usr/bin/perl use Gtk2; Gtk2->init(\@ARGV); my $window = Gtk2::Window->new('toplevel'); my $button = Gtk2::Button->new_with_label("Hello World"); $window->add($button); Gtk2::GSignal->connect($button,"clicked", sub { Gtk2->quit(); r +eturn 0 }); $window->show_all(); Gtk2->main(); exit 0;
When I run this code I get this error message
Usage: init(class) at gtk_example.pl line 3.
Personally I don't have a clue what this means and I thought that I'd post this here while I keep looking around the docs.
Also I love if any one could point me to a good tutorial for using GTK -perl with windows becuase this is my first ever look at it.
Thanks

All the Best, Eoin...

If everything seems to be going well, you obviously don't know what the hell is going on.

Replies are listed 'Best First'.
Re: Usage: init(class) @ GTK
by tcf22 (Priest) on Dec 13, 2003 at 22:08 UTC
    In the CPAN docs it, the calls it init() without any arguments. Try replacing
    Gtk2->init(\@ARGV);
    with
    Gtk2->init();
    Update: when calling a PACKAGE->method(), the class is passed as the first argument automatically. So that is where Usage: init(class) comes in.

    Example:
    #!/usr/bin/perl use strict; use warnings; Tom->init; package Tom; sub init(){ print "Calling init\n"; print "$_\n" for(@_); } __OUTPUT__ Calling init Tom

    - Tom

      tcf22 is correct. Where is the example you quoted so I can report it to the Gtk2 team if is in the Gtk2 stuff? You can also start Gtk2 with use Gtk2 -init; and then init is called for you.

      --traveler

Re: Usage: init(class) @ GTK
by Aristotle (Chancellor) on Dec 14, 2003 at 17:48 UTC
      Valid point. Sorry about that one.

      Cheers.

      P.s. You don't know how to permanently chage the PATH enviroment variable permenantly on Win2000 do you?

      All the Best, Eoin...

      If everything seems to be going well, you obviously don't know what the hell is going on.

        Don't know if it's the same on Windows 2000 but on XP you can right click on My Computer and select properties, on the bottom of the advanced tab is a button for Environment Variables which allows you to change the path (and others) permanently. If that doesn't work you can search the registry for the current value of your path since it is likely stored there.