我能够找到的非常稀疏的wxPerl文档说它是受支持的,当然,我可以创建它的实例。
my $layout = new Wx::GridBagSizer(5,5);
但我不能让它发挥作用。具体来说,我无法将小部件添加到$ layout。有人做过吗?
当我谈到这个主题时,有没有人为wxPerl找到任何好的文档?
答案 0 :(得分:2)
首先,结帐Wx::Demo,了解几乎所有课程的例子。
您应该使用Add
method添加小部件。
$sizer->Add($widget, Wx::GBPosition->new($row, $col));
也许
$sizer->Add($widget, [ $row, $col ]);
答案 1 :(得分:2)
sub new
{
my( $class, $parent ) = @_;
my $self = $class->SUPER::new
(
undef,
-1,
"Wx::GridBagSizer",
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxMAXIMIZE_BOX
);
my $Grid = Wx::GridBagSizer->new(1,1);
$Grid->Add(Wx::Button->new($self, -1, 'Button 1'), Wx::GBPosition->new(0, 0), Wx::GBSpan->new(1, 1), wxGROW|wxALL, 1);
$Grid->Add(Wx::Button->new($self, -1, 'Button 2'), Wx::GBPosition->new(0, 1), Wx::GBSpan->new(1, 1), wxGROW|wxALL, 1);
$Grid->Add(Wx::Button->new($self, -1, 'Button 3'), Wx::GBPosition->new(1, 0), Wx::GBSpan->new(1, 2), wxGROW|wxALL, 1);
$Grid->Add(Wx::Button->new($self, -1, 'Button 4'), Wx::GBPosition->new(2, 0), Wx::GBSpan->new(2, 1), wxGROW|wxALL, 1);
$Grid->Add(Wx::Button->new($self, -1, 'Button 5'), Wx::GBPosition->new(2, 1), Wx::GBSpan->new(1, 1), wxGROW|wxALL, 1);
$Grid->Add(Wx::Button->new($self, -1, 'Button 6'), Wx::GBPosition->new(3, 1), Wx::GBSpan->new(1, 1), wxGROW|wxALL, 1);
$Grid->AddGrowableRow(1);
$Grid->AddGrowableCol(1);
$self->SetAutoLayout( 1 );
$self->SetSizer( $Grid );
$self->CenterOnScreen(wxBOTH);
return $self;
}