http://qs321.pair.com?node_id=429552


in reply to Wx::Panel not rendering

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.