Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

WxPerl and Glade: Wx::App::OnInit redefined

by carcassonne (Pilgrim)
on Jun 03, 2006 at 22:18 UTC ( [id://553452]=perlquestion: print w/replies, xml ) Need Help??

carcassonne has asked for the wisdom of the Perl Monks concerning the following question:


I'm starting to look at WxPerl, using Glade to create forms (to eventually use Wx with POE). So I got this very simple form with one button. I've chosen the option to save in multiple files so that I have the app in one file and the form in another. When done I press the 'generate code' button. Works fine, but upon starting it reports that:

Subroutine Wx::App::OnInit redefined at ./ line 15.

This is code generated by Glade. OnInit is nowhewre to be found elsewhere in the two files. Anyone know how to fix this little problem that does not seem to affect the application's behaviour ?

  • Comment on WxPerl and Glade: Wx::App::OnInit redefined

Replies are listed 'Best First'.
Re: WxPerl and Glade: Wx::App::OnInit redefined
by Tanktalus (Canon) on Jun 04, 2006 at 02:09 UTC

    I'm having a hard time finding line 15 of anything ... perhaps a bit more code would help us.

      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;

        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.
Re: WxPerl and Glade: Wx::App::OnInit redefined
by PodMaster (Abbot) on Jun 08, 2006 at 06:12 UTC
    • wxGlade and Glade are different software.
    • local *Wx::App::OnInit = sub{1}; is what generates the harmless warning.
    • wxGlade generates that particular code because you haven't chosen a name/class for you application.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      And you may need to check the 'overwrite existing sources' box to regenerate the code properly (if you have modified the generated code, you will need to save it and merge your changes back in).

      [I know the thread is several years old, but Google has a long memory.]

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://553452]
Approved by planetscape
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-22 02:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found