Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: GTK2+glade and knowing who called

by Anonymous Monk
on Jan 22, 2013 at 03:41 UTC ( #1014552=note: print w/ replies, xml ) Need Help??


in reply to GTK2+glade and knowing who called

What tutorial are you following?

What is in @_? Is it not the button and event?

You can always interrogate the event object and find the button that called it, see Gtk2::Entry scroll-event/Re^3: Gtk2::Entry scroll-event, Gtk2-Perl: How to catch shift-clicking of a button?


Comment on Re: GTK2+glade and knowing who called
Re^2: GTK2+glade and knowing who called
by ultibuzz (Monk) on Jan 22, 2013 at 10:06 UTC

    no tutorial, im just experimenting with glade GUI

    if i do the whole gtk2 gui in perl code, there is no problem getting what called,but while using a glade GUI,
    it looks like it just calls the sub without any additional info

    some example of the glade file

    <child> <widget class="GtkButton" id="btnNum1"> <property name="label" translatable="yes">1</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <signal name="clicked" handler="btnNUM_clicked"/> </widget> </child> <child> <widget class="GtkButton" id="btnNum2"> <property name="label" translatable="yes">2</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <signal name="clicked" handler="btnNUM_clicked"/> </widget> </child>

    the sub is "btnNUM_clicked", which gets called without problem,but does not tell the code who called ;)

    If changed to "btnNUM_clicked1..3", i know who called, but i want to avoid generating anonymous subs or endless prototyp's,
    if there is a way within glade to pass the who called information.

    kind regard
    Alex

        Not a very helpful link. Many broken links, and of the ones that worked, I didn't see anything showing a solution to the problem mentioned. (I may have missed a page, I can't be certain with all the broken links.

        ...roboticus

        When your only tool is a hammer, all problems look like your thumb.

        the glade itself is describing the form in an XML file,it does not generate perl code.

        example minimal code

        use warnings; use strict; use Gtk2 -init; use Gtk2::GladeXML; my $gladexml = Gtk2::GladeXML->new('register_test.glade'); $gladexml->signal_autoconnect_from_package('main'); Gtk2->main; sub btnNUM_clicked { print "yay clicked"; } sub gtk_main_quit { Gtk2->main_quit; }

        an alternative would be
        use warnings; use strict; use Gtk2 -init; use Gtk2::GladeXML; my $gladexml = Gtk2::GladeXML->new('register_test.glade'); $gladexml->signal_autoconnect_from_package('main'); Gtk2->main; sub btnNUM_clicked { my $self = $_; print "yay,you clicked $self"; } sub gtk_main_quit { Gtk2->main_quit; } sub btnNUM_clicked1 { btnNUM_clicked(1); } sub btnNUM_clicked2 { btnNUM_clicked(2); }

        this would work and can also be automaticaly generated,and inserted in the XML definition,
        but that i would want to avoid, if there is a way from glade telling me who called the event.

        kind regards
        Alex

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014552]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2014-11-26 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls