Hi all

I am making a gui with glade at the moment. Now I've got the gui setup the way I want, but all that's left is to run my scripts from the events.

So I have four text entry boxes that are sitting in a container box. I want the values from them, however in glade you can only pass a single parameter as user data to the callback function.

Is there any way, or how do you pass the multiple text entry boxes to the callback function?

Here is my callback function:

sub OK_clicked_cb { my ( $widget, $entry) = @_; my $entry_text = $entry->get_text(); foreach (@entry){ my $entry_text = $entry[$i]->get_text(); print "$entry_text"; $i++; }

Thanks!

UPDATE!!

Okay I've advanced a bit and got this below

sub OK_clicked_cb { my ( $widget, $entry) = @_; ##Testing stuff my $vbox4 = $builder->get_object('vbox4'); #Have 5 elements, but n +eed 4 my @children = $vbox4->get_children('vbox4'); #Line 40 print "@children\n"; my $i = 0; for ($i < 3){ my $entry_text = $children[$i]->get_text(); print "$entry_text\n"; $i++; } }

This however gives me part of what I need, as it gives the value of the first entry. Here's the terminal output

*** Gtk3::Container::get_children: passed too many parameters (expecte +d 1, got 2); ignoring excess at my-gui.pl line 40 Gtk3::Entry=HASH(0x8ad5e60) Gtk3::Entry=HASH(0x8bda0e8) Gtk3::Entry=HA +SH(0x8bda1ec) Gtk3::Entry=HASH(0x8bda084) Gtk3::Label=HASH(0x8b9641c) 192.168.0.2

SOLVED!!!

I just used the id's of the children and used the following code.

sub OK_clicked_cb { ##Testing stuff my @entry_widgets =0; my @object_names = ("ip-value","ssid-value","psk-value","device-va +lue"); $entry_widgets[0] = $builder->get_object( $object_names[0])->get_t +ext(); $entry_widgets[1] = $builder->get_object( $object_names[1])->get_t +ext(); $entry_widgets[2] = $builder->get_object( $object_names[2])->get_t +ext(); $entry_widgets[3] = $builder->get_object( $object_names[3])->get_t +ext(); print $entry_widgets[0]."\n"; print $entry_widgets[1]."\n"; print $entry_widgets[2]."\n"; print $entry_widgets[3]."\n"; }

For some reason when I was trying to assign values through a loop it wouldn't work, so just did it manually as above. Thanks for all the replies


In reply to Passing multiple user data GLADE by hakim-djz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.