You need to use a sizer like this

#!/usr/bin/perl -- use strict; use warnings; use Wx 0.86 qw( ); our %panel; Main( @ARGV ); exit( 0 ); sub Main { my $app = Wx::SimpleApp->new; my $frame = Wx::Frame->new( undef, -1, "Test window", [ 10, 10 +], [ 400, 600 ], Wx::wxDEFAULT_FRAME_STYLE()|Wx::wxTAB_TRAVERSAL() ); MakePanels( $frame ); my $ShowHideButton = Wx::Button->new( $frame, -1, q[Show(first)/Hi +de(second)] ); Wx::Event::EVT_BUTTON( $frame, $ShowHideButton, \&ShowHidePanels, +); $frame->SetSizer( Wx::BoxSizer->new( Wx::wxVERTICAL() ) ); $frame->GetSizer->Add( $ShowHideButton, 0, Wx::wxEXPAND() ); $frame->GetSizer->Add( $panel{first}, 1, Wx::wxEXPAND() ); $frame->GetSizer->Add( $panel{second}, 1, Wx::wxEXPAND() ); $frame->Show(1); $app->SetTopWindow($frame); $app->MainLoop; } ## end sub Main sub MakePanels { my( $frame ) = @_; $panel{'first'} = Wx::Panel->new( $frame, -1, [ -1, -1 ], [ -1, -1 + ], ); $panel{'first'}->SetBackgroundColour( Wx::wxRED() ); $panel{'first'}->Hide(); Wx::StaticText->new( $panel{'first'}, -1, 'First panel', ); $panel{'second'} = Wx::Panel->new( $frame, -1, [ -1, -1 ], [ -1, - +1 ], ); $panel{'second'}->Show(); $panel{'second'}->SetBackgroundColour( Wx::wxBLUE() ); Wx::StaticText->new( $panel{'second'}, -1, 'Second panel' ); return; } ## end sub MakePanels sub ShowHidePanels { my ( $frame, $event ) = @_; my $button = $event->GetEventObject; my $label = $button->GetLabel(); if ( $label eq 'Show(first)/Hide(second)' ) { $label = 'Hide(first)/Show(second)'; $panel{first}->Show(); $panel{second}->Hide(); $frame->GetSizer->Layout(); ##!!!! } else { $label = 'Show(first)/Hide(second)'; $panel{first}->Hide(); $panel{second}->Show(); $frame->GetSizer->Layout(); ##!!!! } $button->SetLabel($label); } ## end sub ShowHidePanels

In reply to Re^3: Wxperl child window destroy ( hide/show wxpanel in same wxframe ) by Anonymous Monk
in thread Wxperl child window destroy by vinothjaguva

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.