Hi,
being curious I digged around a bit having more or less no clue about the building blocks of wxPerl, but I got a little nice looking window with the following code:
use strict;
use warnings;
use Wx;
use Carp qw {cluck};
package MainWindow;
use Wx ':everything';
use parent -norequire, 'Wx::Frame';
sub new {
my $class = shift;
my $self = $class->SUPER::new(
undef,
-1,
'Test',
[-1, -1],
[-1, -1],
);
# we need a panel
my $panel = Wx::Panel->new($self);
$panel->SetBackgroundColour(wxGREEN);
$self->{panel} = $panel;
# create a list control with content
my $lc = Wx::ListCtrl->new(
$panel,
-1,
wxDefaultPosition,
wxDefaultSize,
wxLC_REPORT,
);
$lc->InsertColumn(0, 'Column1', wxLIST_FORMAT_LEFT, 150);
$lc->InsertColumn(1, 'Column2', wxLIST_FORMAT_LEFT, 150);
for my $i (1..10) {
my $id = $lc->InsertStringItem($i, "Item $i");
$lc->SetItem($id, 1, $i, -1);
$lc->SetItemData($id, 100 + $i);
}
$self->{list} = $lc;
# put sizers in
my $panelsizer = Wx::BoxSizer->new(wxVERTICAL);
my $mainsizer = Wx::BoxSizer->new(wxVERTICAL);
$panelsizer->Add($lc, 1, wxEXPAND|wxALL, 0);
$panel->SetSizer($panelsizer);
$mainsizer->Add($panel, 1, wxEXPAND|wxALL, 0);
$self->SetSizer( $mainsizer );
return $self;
}
my $app = Wx::SimpleApp->new;
my $win = MainWindow->new;
$win->Show(1);
$app->MainLoop;
Probably it helps you to find out what was wrong initially.
McA
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.