#!/usr/bin/perl use Wx; use warnings; package MyApp; use strict; use vars qw( @ISA ); @ISA = qw( Wx::App ); sub OnInit { my $self = shift; my $frame = MyFrame->new("Dungeon Construction Kit", [50,50], [450,350]); $self->SetTopWindow($frame); $frame->Show( 1 ); 1; } package MyFrame; use strict; use vars qw( @ISA ); @ISA = qw( Wx::Frame ); sub new { my $class = shift; my ($title, $pts, $size) = @_; my $self = $class->SUPER::new( undef, -1, $title, Wx::Point->new(@$pts), Wx::Size->new(@$size), ); # create the menus my $menubar = Wx::MenuBar->new(); my $file_menu = Wx::Menu->new; my ($ID_MAKE_PANEL, $ID_EXIT) = 1 .. 1000; $file_menu->Append($ID_MAKE_PANEL, "&New\tCtrl+N", "Create a new panel"); $file_menu->Append($ID_EXIT, "E&xit\tCtrl+X", "Quit"); $menubar->Append($file_menu, "&File"); $self->SetMenuBar($menubar); use Wx::Event qw( EVT_MENU ); # uncomment the next line, and a panel is drawn # Wx::Panel->new($self); # when the "New" menu item is activated, a panel should render EVT_MENU($self, $ID_MAKE_PANEL, sub { Wx::Panel->new($self) }); EVT_MENU($self, $ID_EXIT, sub { $self->Close(1) }); $self; } package main; MyApp->new->MainLoop();