OS: WinXP
Perl: ActiveState 5.8.3 build 809
wxPerl: 0.19
With your original code if I minimise then maximise the window the panel appears. So my guess is the window needs to be redrawn for the panel to appear. I tried doing a $self->Refresh inside the menu callback but that did not work for me.
I made the following changes to have it appear automatically:
...
# when the "New" menu item is activated, a panel should render
EVT_MENU($self, $ID_MAKE_PANEL, \&_make_panel );
EVT_MENU($self, $ID_EXIT, sub { $self->Close(1) });
$self;
}
sub _make_panel {
my ( $self ) = @_;
return if exists $self->{'panel'};
use Wx qw( wxVERTICAL wxGROW );
my $panel = Wx::Panel->new( $self, # parent
-1, # id
[ -1, -1 ], # position
[ 200, 200 ] ); # size
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
$sizer->Add( $panel, 1, wxGROW );
$self->SetSizer($sizer);
$sizer->SetSizeHints($self);
$self->{'panel'} = $panel;
}
...
Using the sizer to resize the window after the panel is created makes it appear for me. Of course the frame changes size as well which may not be what you are after.
I am not sure if this is what you are after or if it helps at all.
-
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.