Read contents of Gtk2::Entry and Gtk2::ComboBox when button is pressed

Hi Brian,

I understand that I have to read the controls in the callback of the
'clicked' event of the button. What I don't understand is how to read
those controls, how to express them in code. Like how to get the
contents of the first Gtk2::Entry at that moment. Currently I can only
print that info out when the user is typing something in that

On Sat, Nov 20, 2010 at 2:09 AM, Brian Manning <elspicyjack gmail com> wrote:
On Fri, Nov 19, 2010 at 8:52 AM, haratron <haratron gmail com> wrote:
At the moment, I have 3 Gtk2::Entry and 3 Gtk2::ComboBox objects.
I want to read their contents when a button is pressed (the OK button).
To illustrate better, the user is entering his data (Entry) and makes
his selections (ComboBox) and hits a button that reads "OK" . At that
moment, I want to read in the contents of each Entry and Combobox.

Following is the code that I currently have (handles only one Entry
and one ComboBox). What changes should I do to accomplish the above?

From IRC:

16:01 < ebassi> cfx: if you want to read in response to signals from other
               widgets - like a GtkButton::clicked signal - read the contents
               of the entry from that callback

So you should be reading your controls in the callback for the
'clicked' event (the sub{} block below).

$button= $builder->get_object('button1');

$button->signal_connect('clicked' => sub {my ($button,$userdata) =

The documentation section of the Gtk2-Perl website [1] has a tutorial
[2] that comes with live code examples that could help you work out
the rest of your question above.  There's also the demos/examples in
the Gtk2-Perl git tree, as mentioned by Emmanuele in IRC[3], that will
have examples of callbacks for the 'clicked' event.





[3] 03:38 < ebassi> and

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