Help with get_text() for Gtk3::Entry widget
- From: tsuyoshi okita <825864 gmail com>
- To: gtk-perl-list gnome org
- Subject: Help with get_text() for Gtk3::Entry widget
- Date: Mon, 14 Apr 2014 14:40:21 +0900
Hello, I am a Gtk3+ newbie. I'm having a trouble with get_text() using
Gtk3::Entry.
It works fine if I call Gtk3::Entry->new to an ordinary scalar variable
like my $entry = Gtk3::Entry->new;But if I tried to add a Entry
reference to an array or symbol referenced formatted name , I get the
following error message:
*** unhandled exception in callback:
*** Can't call method "get_text" on an undefined value at
lib/Tsuyoshi/Gtk3.pm line 242.
*** ignoring at /usr/share/perl5/Gtk3.pm line 137.
This is my code snippet:
my $row_num = 5;
my $max_row_num = 9;
my $image_num = 1;
no strict 'refs';
for my $i ( $row_num...$max_row_num){
no strict 'refs';
${"recipient_entry_".$i};
${"recipient_image_".$i};
}
my $add_recipient_button =
$builder->get_object('add_recipient_button');
$add_recipient_button->signal_connect( clicked => sub {
if ($row_num > $max_row_num) { return; }
${"recipient_entry_".$row_num} = Gtk3::Entry->new;
${"recipient_image_".$row_num} =
Gtk3::Image->new_from_stock('gtk-cancel',2);
print "var = ".${"recipient_entry_".$row_num},
"\n";
print "var = ".${"recipient_image_".$row_num},
"\n";
$page2_grid->attach(${"recipient_entry_".$row_num},1,$row_num,1,1);
$page2_grid->attach(${"recipient_image_".$row_num},2,$row_num,1,1);
${"recipient_entry_".$row_num}->signal_connect( changed => sub {
my $recipient_email =
${"recipient_entry_".$row_num}->get_text;
if ( $recipient_email ne ""){
my $email_obj = Email::Valid->new(
-mxcheck => 1,
-allow_ip=> 0);
my $checked_address =
$email_obj->address($recipient_email);
if ($checked_address){
${"recipient_image_".$row_num}->set_from_stock('gtk-apply', 2);
$first_page_check{'email'} = 1;
}else{
${"recipient_image_".$row_num}->set_from_stock('gtk-cancel', 2);
$first_page_check{'recipient'} = 0;
} # if2
}else{
${"recipient_image_".$row_num}->clear;
$first_page_check{'recipient'} = 0;
}
if ( $first_page_check{'recipient'} ==
1 && $first_page_check{'port'} == 1 && $first_page_check{'email'} == 1 ) {
$assistant->set_page_complete($page2_grid, 1);
} # if
} # sub
); # signal_connect
$page2_grid->show_all;
$row_num++;
$image_num++;
} # sub
); # signal_connect
use strict 'refs';
Thank you for your help.
Yoshi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]