### MyMenuBar package MyMenuBar; use Moo; #use Moose; #use MooseX::NonMoose::InsideOut; use Wx qw(:everything); extends 'Wx::MenuBar'; sub FOREIGNBUILDARGS { return (); } sub BUILD { my $self = shift; $self->Append( MenuBar::Item->new, 'Item'); # comment this line to # get the object info return $self; } ### MenuBar::Item package MenuBar::Item; use Moo; #use Moose; #use MooseX::NonMoose::InsideOut; use Wx qw(:everything); extends 'Wx::MenuItem'; has 'item_quit' => ( is => 'ro', lazy => 1, builder => '_build_item_quit', ); sub _build_item_quit { my $self = shift; return Wx::MenuItem->new( $self, wxID_EXIT, '&Quit', 'Quit', wxITEM_NORMAL, undef # if defined, this is a sub-menu ); } sub FOREIGNBUILDARGS { return (); # Wx::Menu->new() takes no arguments } sub BUILD { my $self = shift; $self->Append( $self->item_quit ); return $self; } ### MyStatusBar package MyStatusBar; use Moo; #use Moose; #use MooseX::NonMoose::InsideOut; use Wx qw(:everything); extends 'Wx::StatusBar'; sub FOREIGNBUILDARGS { my $self = shift; my %args = @_; return ( $args{parent}, -1, $args{style}, $args{name}, ); } ### MyFrame package MyFrame; use Moo; #use Moose; #use MooseX::NonMoose::InsideOut; use Data::Printer; use Wx qw(:everything); extends 'Wx::Frame'; use MyStatusBar; use MyMenuBar; sub FOREIGNBUILDARGS { my $self = shift; my %args = @_; return ( undef, -1, 'Wx with Moo', [ -1, -1 ], [ -1, -1 ], wxDEFAULT_FRAME_STYLE, ); } sub BUILD { my $self = shift; my $panel = Wx::Panel->new( $self, -1, [ -1, -1 ], [ -1, -1 ] ); my $sizer = Wx::BoxSizer->new(wxVERTICAL); my $status_bar = MyStatusBar->new( parent => $self, name => 'sb', style => 0, ); p $status_bar; $status_bar->SetStatusText('Status', 0); my $menu_bar = MyMenuBar->new; p $menu_bar; $self->SetMenuBar($menu_bar); $panel->SetSizerAndFit($sizer); return $self; } ### main package main; use 5.010; use strict; use warnings; use Wx; my $app = Wx::SimpleApp->new; my $frame = MyFrame->new; $frame->Show(1); $app->MainLoop; #### MyStatusBar { Parents Wx::StatusBar public methods (2) : FOREIGNBUILDARGS, new private methods (0) internals: {} } Can't locate object method "item_quit" via package "Wx::Menu" at wx-moo-menu-problem.pl line 58. #### Wx::MenuBar { Parents Wx::Window public methods (28) : Append, Check, Enable, EnableTop, FindItem, FindMenu, FindMenuItem, ... private methods (0) internals: 49230256 }