0
충돌 레이아웃을 생성하는 코드는 wxGlade에 의해 생성되었습니다. "펄 통역원의 작동이 중지되었습니다"오류에 이 코드의 결과는 : 검증은 내가 사용하고 펄 인터프리터
use Wx 0.15 qw[:allclasses];
use strict;
# begin wxGlade: dependencies
# end wxGlade
# begin wxGlade: extracode
# end wxGlade
package MyFrame;
use Wx;
use Wx qw[:everything];
use Wx::Event qw(EVT_BUTTON EVT_CLOSE);
use Wx::Perl::TextValidator;
use base qw(Wx::Frame Class::Accessor::Fast);
use strict;
use Wx::Locale gettext => '_T';
__PACKAGE__->mk_ro_accessors(qw(numeric string));
sub new {
my($self, $parent, $id, $title, $pos, $size, $style, $name) = @_;
$parent = undef unless defined $parent;
$id = -1 unless defined $id;
$title = "" unless defined $title;
$pos = wxDefaultPosition unless defined $pos;
$size = wxDefaultSize unless defined $size;
$name = "" unless defined $name;
# begin wxGlade: MyFrame::new
$style = wxDEFAULT_FRAME_STYLE
unless defined $style;
my $numval = Wx::Perl::TextValidator->new('\d');
$self = $self->SUPER::new($parent, $id, $title, $pos, $size, $style, $name);
$self->{text_ctrl_1} = Wx::TextCtrl->new($self, wxID_ANY, "", wxDefaultPosition, wxDefaultSize,);
$self->{button_1} = Wx::Button->new($self, wxID_ANY, _T("Get"));
$self->{label_1} = Wx::StaticText->new($self, wxID_ANY, _T("From:"), wxDefaultPosition, wxDefaultSize,);
$self->{text_ctrl_2} = $self->{numeric} = Wx::TextCtrl->new($self, wxID_ANY, "", wxDefaultPosition, wxDefaultSize,);
$self->{label_2} = Wx::StaticText->new($self, wxID_ANY, _T("To: "), wxDefaultPosition, wxDefaultSize,);
$self->{text_ctrl_3} = $self->{numeric} = Wx::TextCtrl->new($self, wxID_ANY, "", wxDefaultPosition, wxDefaultSize,);
$self->{radio_box_1} = Wx::RadioBox->new($self, wxID_ANY, _T("Vote?"), wxDefaultPosition, wxDefaultSize, [_T("Yes"), _T("No")], 2, wxRA_SPECIFY_ROWS);
$self->{text_ctrl_4} = Wx::TextCtrl->new($self, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
$self->__set_properties();
$self->__do_layout();
# end wxGlade
$self->{text_ctrl_2}->SetValidator ($numval); #<- this is where the program crashes
$self->{text_ctrl_3}->SetValidator ($numval); #<- this WORKS actually
EVT_BUTTON(
$self,
$self->{button_1},
\&GetURL
);
EVT_CLOSE(
$self,
\&OnClose
);
return $self;
}
나는 두 textctrl 년대의 숫자 검증을 시도하기 전에 오류 없었다. 내가하려는 것은 내 분야의 숫자 만 받아들이는 것입니다.
내 설명서로 wxperl_demo를 사용하고 있습니다.
제 2의 SetValidator가 작동하고 있다는 사실이 나에게 흥미 롭다. 무엇이 문제 일까?