有人在 Wx Perl 中使用过 Wx::GridBagSizer 布局管理器吗?

发布于 2024-12-09 11:22:18 字数 210 浏览 1 评论 0原文

我找到的非常稀疏的 wxPerl 文档说它是受支持的,而且果然,我可以创建它的一个实例。

my $layout = new Wx::GridBagSizer(5,5);

但我无法让它发挥作用。具体来说,我无法将小部件添加到 $layout。有人做过这个吗?

当我谈论这个主题时,有没有人找到 wxPerl 的任何好的文档?

The very sparse wxPerl documentation that I have been able to find says it is supported and sure enough, I can create an instance of it.

my $layout = new Wx::GridBagSizer(5,5);

But I cannot make it work. Specifically, I cannot add a widget to $layout. Anyone done this?

And while I am on the subject, has anyone found any GOOD documentation for wxPerl?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

与君绝 2024-12-16 11:22:18

首先,查看 Wx::Demo 以获取几乎每个类的示例。

您应该使用其 Add 方法 添加小部件。

$sizer->Add($widget, Wx::GBPosition->new($row, $col));

也许

$sizer->Add($widget, [ $row, $col ]);

First, checkout Wx::Demo for examples of just about every class.

You should add widgets using its Add method.

$sizer->Add($widget, Wx::GBPosition->new($row, $col));

and maybe

$sizer->Add($widget, [ $row, $col ]);
雪若未夕 2024-12-16 11:22:18

池上让我朝着正确的方向前进。 Wx::Demo 非常有帮助(就像 PerlTk 的小部件,如果有人熟悉该工具的话)。但 Wx::GridBagSizer 没有明确讨论,因此需要经过一些尝试和错误才能最终实现。这是我试图做的:

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;
}

ikegami got me going in the right direction. Wx::Demo was VERY helpful (like widget for PerlTk if anyone is familiar with that tool). But Wx::GridBagSizer is not explicitly discussed so it took some trial and error to finally get there. Here is what I was trying to do:

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文