in reply to Re: WxPerl and Glade: Wx::App::OnInit redefined
in thread WxPerl and Glade: Wx::App::OnInit redefined

I first thought that this question would target people who specifically know how Glade works when it generates Perl code, because I suppose this is a bug with Glade. Here goes the entire code for

use Wx 0.15 qw[:allclasses]; use strict; 1; package main; use MyFrame8; unless(caller){ local *Wx::App::OnInit = sub{1}; my $app = Wx::App->new(); Wx::InitAllImageHandlers(); my $frame_9 = MyFrame8->new(); $app->SetTopWindow($frame_9); $frame_9->Show(1); $app->MainLoop(); } is also generated by Glade and it has a bit more code that makes the frame. Still, there's no OnInit in there. The only OnInit is the one above, also generated by Glade. Here's then:

use Wx 0.15 qw[:allclasses]; use strict; package MyFrame8; use Wx qw[:everything]; use base qw(Wx::Frame); use strict; # begin wxGlade: ::dependencies # end wxGlade sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_ +; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; # begin wxGlade: MyFrame8::new $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $sty +le, $name ); $self->{panel_1} = Wx::Panel->new($self, -1, wxDefaultPosition, wx +DefaultSize, ); $self->{label_1} = Wx::StaticText->new($self->{panel_1}, -1, "labe +l_1", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); $self->{Test} = Wx::Button->new($self->{panel_1}, -1, "Test"); $self->__set_properties(); $self->__do_layout(); # end wxGlade return $self; } sub __set_properties { my $self = shift; # begin wxGlade: MyFrame8::__set_properties $self->SetTitle("frame_9"); $self->SetSize(Wx::Size->new(400, 300)); # end wxGlade } sub __do_layout { my $self = shift; # begin wxGlade: MyFrame8::__do_layout $self->{sizer_9} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_10} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_11} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_10}->Add($self->{label_1}, 1, wxALIGN_CENTER_HORIZON +TAL, 0); $self->{sizer_11}->Add(0, 78, 0, wxADJUST_MINSIZE, 0); $self->{sizer_11}->Add($self->{Test}, 0, wxALIGN_CENTER_HORIZONTAL +, 0); $self->{sizer_10}->Add($self->{sizer_11}, 1, wxALL|wxEXPAND, 0); $self->{panel_1}->SetAutoLayout(1); $self->{panel_1}->SetSizer($self->{sizer_10}); $self->{sizer_10}->Fit($self->{panel_1}); $self->{sizer_10}->SetSizeHints($self->{panel_1}); $self->{sizer_9}->Add($self->{panel_1}, 1, wxEXPAND, 0); $self->SetAutoLayout(1); $self->SetSizer($self->{sizer_9}); $self->Layout(); # end wxGlade } # end of class MyFrame8 1;

Replies are listed 'Best First'.
Re^3: WxPerl and Glade: Wx::App::OnInit redefined
by SheridanCat (Pilgrim) on Jun 04, 2006 at 16:06 UTC
    What O/S and Perl are you using? I was able to run this just fine on Windows XP SP2 with Perl 5.8.8 and the latest wx stuff.
      I'm using;

      OS: SuSE 10.0 X86_64

      Perl: 5.8.7 (included with SuSE)

      WxPerl: Wx-0.27

      wxWidgets: (included with SuSE)