Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How do I set the menu item icon in wxPerl?

by Anonymous Monk
on May 12, 2011 at 07:36 UTC ( [id://904306]=note: print w/replies, xml ) Need Help??


in reply to How do I set the menu item icon in wxPerl?

Once you Append its too late change it
my $item = Wx::MenuItem->new( $parent ... ); $item->SetBitmap( ... ); $parent->Append( $item );
#!/usr/bin/perl -- use strict; use warnings; use Wx 0.98 (); Main( @ARGV ); exit( 0 ); sub Main { my $app = Wx::SimpleApp->new; my $frame = Wx::Frame->new(undef,-1,'Menu Icon Test'); my $menu1 = Wx::Menu->new();; for my $icon ( Wx::Bitmap->new( Wx::GetWxPerlIcon() ), #~ $ perl -MWx=:everything -le " print for grep /wxICON_/, keys %:: " +>1 qw[ wxICON_QUESTION wxICON_HAND wxICON_INFORMATION wxICON_WARNING wxICON_ERROR wxICON_EXCLAMATION ] ){ my $bmp = $icon ; if( not ref $icon ){ $bmp = Wx::Bitmap->new( $app->GetStdIcon( Wx->$icon ) ); } my $item = Wx::MenuItem->new( $menu1 , -1 , "$icon $bmp"); $item->SetBitmap( $bmp ); $menu1->Append( $item ); } my $menu1item = $menu1->Append( Wx::wxID_EXIT(), "E&xit", "Quit to +olbar sample" ); $menu1item->SetBitmap ( Wx::Bitmap->new( Wx::GetWxPerlIcon() ) ); +## too late # Creates menu bar my $menubar = Wx::MenuBar->new(); $menubar->Append($menu1, "File"); # Attach menubar to the window $frame->SetMenuBar($menubar); $frame->Show(); Wx::Event::EVT_MENU( $frame, Wx::wxID_EXIT(), sub { $_[0]->Destroy + } ); $app->SetTopWindow($frame); $app->MainLoop(); } __END__

Replies are listed 'Best First'.
Re^2: How do I set the menu item icon in wxPerl?
by ZJ.Mike.2009 (Scribe) on May 12, 2011 at 08:06 UTC
    Thank you, Anonymous Monk! This is very enlightening! :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://904306]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-24 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found