Read contents of Gtk2::Entry and Gtk2::ComboBox when button is pressed
- From: haratron <haratron gmail com>
- To: gtk-perl-list gnome org
- Subject: Read contents of Gtk2::Entry and Gtk2::ComboBox when button is pressed
- Date: Fri, 19 Nov 2010 18:52:27 +0200
I'm using Glade3 and Perl to make a Gtk GUI.
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?
$window= $builder->get_object('window1');
$window->set_border_width(0);
$window->set_position('center_always');
$window->signal_connect( "destroy" => sub {
Gtk2->main_quit;
});
$engine_cbox= $builder->get_object('combobox1');
my $model1 = new Gtk2::ListStore('Glib::String');
$engine_cbox->clear();
my $renderer1 = new Gtk2::CellRendererText;
$engine_cbox->pack_start($renderer1, FALSE);
$engine_cbox->set_attributes($renderer1, text => 0);
$engine_cbox->set_model($model1);
my @listing = qw/a b c d/;
foreach $text (@listing) {
$engine_cbox->append_text ($text)
}
$engine_cbox->set_active(1);
$engine=$engine_cbox->get_active_text();
print "engine is $engine\n";
$source_Entry= $builder->get_object('entry1');
# $sourceimg= $source_Entry->get_text;
# $source_Entry->signal_connect(changed => \&convert, $source_Entry);
$source_Entry->signal_connect(changed => \&convert, $source_Entry);
$button= $builder->get_object('button1');
$button->signal_connect('clicked' => sub {my ($button,$userdata) =
@_;},$userdata);
$window->show();
$builder =undef;
Gtk2->main();
exit;
sub convert {
($widget, $data) = @_;
$text = $data->get_text();
# print "$text and $engine\n";
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]