From: Manfred H. <m.h...@ki...> - 2006-07-11 21:07:05
|
Hello, i have little bit extend the minimal.pl example with two panel's in the subroutine Ps and Ps1. When i switch from Ps to Ps1 in the MenUBar, the StaticText isn't show correctly. I believe i must rehash the panel or write the panel new? Have someone an idea what i doing wrong here? Manfred #!/usr/bin/perl use Wx; package MyApp; use strict; use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my( $this ) = @_; # create new MyFrame my( $frame ) = MyFrame->new( "Minimal wxPerl app", Wx::Point->new( 50, 50 ), Wx::Size->new( 450, 350 ) ); $this->SetTopWindow( $frame ); # show the frame $frame->Show( 1 ); 1; } package MyFrame; use strict; use vars qw(@ISA); @ISA=qw(Wx::Frame); use Wx::Event qw(EVT_MENU); use Wx qw(wxBITMAP_TYPE_ICO wxMENU_TEAROFF); # Parameters: title, position, size sub new { my( $class ) = shift; my( $this ) = $class->SUPER::new( undef, -1, $_[0], $_[1], $_[2] ); # load an icon and set it as frame icon $this->SetIcon( Wx::GetWxPerlIcon() ); # create the menus my( $mfile ) = Wx::Menu->new( undef, wxMENU_TEAROFF ); my( $mhelp ) = Wx::Menu->new(); my( $ID_ABOUT, $ID_EXIT, $ID_PS, $ID_PS1 ) = ( 1, 2, 3, 4 ); $mhelp->Append( $ID_ABOUT, "&About...\tCtrl-A", "Show about dialog" ); $mhelp->Append( $ID_PS, "&PS...\tCtrl-P", "PS" ); $mhelp->Append( $ID_PS1, "&PS1...\tCtrl-P", "PS1" ); $mfile->Append( $ID_EXIT, "E&xit\tAlt-X", "Quit this program" ); my( $mbar ) = Wx::MenuBar->new(); $mbar->Append( $mfile, "&File" ); $mbar->Append( $mhelp, "&Help" ); $this->SetMenuBar( $mbar ); # declare that events coming from menu items with the given # id will be handled by these routines EVT_MENU( $this, $ID_EXIT, \&OnQuit ); EVT_MENU( $this, $ID_ABOUT, \&OnAbout ); EVT_MENU( $this, $ID_PS, \&Ps ); EVT_MENU( $this, $ID_PS1, \&Ps1 ); # create a status bar (note that the status bar that gets created # has three panes, see the OnCreateStatusBar callback below $this->CreateStatusBar( 1 ); # and show a message $this->SetStatusText( "Welcome to wxPerl!", 1 ); #my( $panel ) = Wx::Panel->new( $this, -1 ); $this; } # this is an addition to demonstrate virtual callbacks... # it ignores all parameters and creates a status bar with three fields sub OnCreateStatusBar { my( $this ) = shift; my( $status ) = Wx::StatusBar->new( $this, -1 ); $status->SetFieldsCount( 2 ); $status; } # called when the user selects the 'Exit' menu item sub OnQuit { my( $this, $event ) = @_; # closes the frame $this->Close( 1 ); } use Wx qw(wxOK wxICON_INFORMATION wxVERSION_STRING wxVERTICAL wxLEFT); # called when the user selects the 'About' menu item sub OnAbout { my( $this, $event ) = @_; # display a simple about box Wx::MessageBox( "This is the about dialog of minimal sample.\n" . "Welcome to wxPerl " . $Wx::VERSION . "\n" . wxVERSION_STRING, "About minimal", wxOK | wxICON_INFORMATION, $this ); } sub Ps { my( $this, $event ) = @_; print"Hallo Ps \n"; my $panel = Wx::Panel->new( $this, -1); my $label = new Wx::StaticText( $panel, -1, "Bitte Ps !",[ 20, 20 ], [ 250, 15 ] ); my $r0_sizer = Wx::BoxSizer->new(wxVERTICAL); $r0_sizer->Add($label,0, wxLEFT, 5); $panel->SetSizer($r0_sizer); $panel->SetAutoLayout(1); } sub Ps1 { my( $this, $event ) = @_; print"Hallo Ps1 \n"; my $panel = Wx::Panel->new( $this, -1); my $label = new Wx::StaticText( $panel, -1, "Bitte Ps1!",[ 20, 20 ], [ 250, 15 ] ); my $r0_sizer = Wx::BoxSizer->new(wxVERTICAL); $r0_sizer->Add($label,0, wxLEFT, 5); $panel->SetSizer($r0_sizer); $panel->SetAutoLayout(1); } package main; # create an instance of the Wx::App-derived class my( $app ) = MyApp->new(); # start processing events $app->MainLoop(); |
From: Manfred H. <m.h...@ki...> - 2006-07-13 15:38:26
|
Hello, i have solve my problem. in the "new" subroutine, i create a new panel object. $this->{panel} = Wx::Panel->new( $this, -1); after that in the ps and ps1 subroutine, i destroy the panel and create a new one. The old StaticText from ps or ps1 will be delete. Manfred Am Dienstag, den 11.07.2006, 22:03 +0200 schrieb Manfred Hansen: > Hello, > > i have little bit extend the minimal.pl example with two panel's in the > subroutine Ps and Ps1. > > When i switch from Ps to Ps1 in the MenUBar, the StaticText isn't show > correctly. > I believe i must rehash the panel or write the panel new? > > Have someone an idea what i doing wrong here? > > Manfred > > #!/usr/bin/perl > > use Wx; > > package MyApp; > > use strict; > use vars qw(@ISA); > > @ISA=qw(Wx::App); > > sub OnInit { > my( $this ) = @_; > > # create new MyFrame > my( $frame ) = MyFrame->new( "Minimal wxPerl app", > Wx::Point->new( 50, 50 ), > Wx::Size->new( 450, 350 ) > ); > > $this->SetTopWindow( $frame ); > # show the frame > $frame->Show( 1 ); > > 1; > } > > package MyFrame; > > use strict; > use vars qw(@ISA); > > @ISA=qw(Wx::Frame); > > use Wx::Event qw(EVT_MENU); > use Wx qw(wxBITMAP_TYPE_ICO wxMENU_TEAROFF); > > # Parameters: title, position, size > sub new { > my( $class ) = shift; > my( $this ) = $class->SUPER::new( undef, -1, $_[0], $_[1], $_[2] ); > > # load an icon and set it as frame icon > $this->SetIcon( Wx::GetWxPerlIcon() ); > > # create the menus > my( $mfile ) = Wx::Menu->new( undef, wxMENU_TEAROFF ); > my( $mhelp ) = Wx::Menu->new(); > > my( $ID_ABOUT, $ID_EXIT, $ID_PS, $ID_PS1 ) = ( 1, 2, 3, 4 ); > $mhelp->Append( $ID_ABOUT, "&About...\tCtrl-A", "Show about dialog" ); > $mhelp->Append( $ID_PS, "&PS...\tCtrl-P", "PS" ); > $mhelp->Append( $ID_PS1, "&PS1...\tCtrl-P", "PS1" ); > $mfile->Append( $ID_EXIT, "E&xit\tAlt-X", "Quit this program" ); > > my( $mbar ) = Wx::MenuBar->new(); > > $mbar->Append( $mfile, "&File" ); > $mbar->Append( $mhelp, "&Help" ); > > $this->SetMenuBar( $mbar ); > > # declare that events coming from menu items with the given > # id will be handled by these routines > EVT_MENU( $this, $ID_EXIT, \&OnQuit ); > EVT_MENU( $this, $ID_ABOUT, \&OnAbout ); > EVT_MENU( $this, $ID_PS, \&Ps ); > EVT_MENU( $this, $ID_PS1, \&Ps1 ); > > # create a status bar (note that the status bar that gets created > # has three panes, see the OnCreateStatusBar callback below > $this->CreateStatusBar( 1 ); > # and show a message > $this->SetStatusText( "Welcome to wxPerl!", 1 ); > > #my( $panel ) = Wx::Panel->new( $this, -1 ); > > $this; > } > > # this is an addition to demonstrate virtual callbacks... > # it ignores all parameters and creates a status bar with three fields > sub OnCreateStatusBar { > my( $this ) = shift; > my( $status ) = Wx::StatusBar->new( $this, -1 ); > > $status->SetFieldsCount( 2 ); > > $status; > } > > # called when the user selects the 'Exit' menu item > sub OnQuit { > my( $this, $event ) = @_; > > # closes the frame > $this->Close( 1 ); > } > > use Wx qw(wxOK wxICON_INFORMATION wxVERSION_STRING wxVERTICAL wxLEFT); > > # called when the user selects the 'About' menu item > sub OnAbout { > my( $this, $event ) = @_; > > # display a simple about box > Wx::MessageBox( "This is the about dialog of minimal sample.\n" . > "Welcome to wxPerl " . $Wx::VERSION . "\n" . > wxVERSION_STRING, > "About minimal", wxOK | wxICON_INFORMATION, > $this ); > } > > sub Ps { > my( $this, $event ) = @_; > print"Hallo Ps \n"; > my $panel = Wx::Panel->new( $this, -1); > my $label = new Wx::StaticText( $panel, -1, "Bitte Ps !",[ 20, 20 ], > [ 250, 15 ] ); > > my $r0_sizer = Wx::BoxSizer->new(wxVERTICAL); > $r0_sizer->Add($label,0, wxLEFT, 5); > $panel->SetSizer($r0_sizer); > $panel->SetAutoLayout(1); > } > > sub Ps1 { > my( $this, $event ) = @_; > print"Hallo Ps1 \n"; > my $panel = Wx::Panel->new( $this, -1); > my $label = new Wx::StaticText( $panel, -1, "Bitte Ps1!",[ 20, 20 ], > [ 250, 15 ] ); > my $r0_sizer = Wx::BoxSizer->new(wxVERTICAL); > $r0_sizer->Add($label,0, wxLEFT, 5); > $panel->SetSizer($r0_sizer); > $panel->SetAutoLayout(1); > } > > package main; > > # create an instance of the Wx::App-derived class > my( $app ) = MyApp->new(); > # start processing events > $app->MainLoop(); > > > > > > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > wxperl-users mailing list > wxp...@li... > https://lists.sourceforge.net/lists/listinfo/wxperl-users |