perl Gtk annoyances

By scragar

I have been learning perl for a long time, and even now I can’t get my head around the usage of Gtk2, I’m sure for those that are experts it’s so simple they can’t imagine where to start a guide, but to me it’s an annoyance, let’s run over some fun things:

we’ll start by assuming I’ve created a window with a nice standard destroy event:


    my $win = Gtk2::Window->new('toplevel');
    $win->set_title( 'autoBUMP' );
    $win->signal_connect(delete_event => \&delete_event);
    $win->signal_connect(destroy => sub { Gtk2->main_quit; });

what happens when I call it?


$window->destroy;

all you perl experts should know that the answer here depends, why I’m unsure, but it does.
it we have called


Gtk2->main;

then it hops back to where it was started and continues, completely losing some functions I had prepared.
if we hadn’t called the function however the window is destroyed and the code continues, but wait, calling


Gtk2->main_quit;

first it doesn’t leap back like it does when it’s activated from within the anonymous sub attached to the destroy event. WTF?

Let’s pick another thing that can be rather confusing, please remember that I come from a background of javascript, ASP and PHP programming(of course no-one can really consider ASP a real language, the entire language appears to have been built as an OOP language without classes…), I come from languages where when navigating a document you can do:


document.documentElement.childNodes()

to get a list of children in the document, or even grab of children of a given type:


document.getElementsByTagName('somethingHere');

yet in perl I don’t know of any such methods, so instead I’m forced to keep references to all the elements I need in variables, I’m currently working on a basic input/output system using a few Gtk2::entry boxes, a text file, and a few pretty functions, yet ram using is huge.

Oh, if anyone could give me a guide to creating a notification area icon in perl would be a great help.

Leave a Reply