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

How do I set the menu item icon in wxPerl?

by ZJ.Mike.2009 (Scribe)
on May 12, 2011 at 04:03 UTC ( #904291=perlquestion: print w/replies, xml ) Need Help??

ZJ.Mike.2009 has asked for the wisdom of the Perl Monks concerning the following question:

The following piece of code demonstrates my problem. Where am I doing wrong? Thanks for any help.
use warnings; use strict; package MyApp; use Wx qw(:everything); use base 'Wx::App'; #Loads a 16x16 BMP image my $bmp = Wx::Bitmap->new("exit.bmp",wxBITMAP_TYPE_BMP); sub OnInit { my $frame = Wx::Frame->new(undef,-1,'Menu Icon Test'); # Creates menus my $menu1 = Wx::Menu->new(); my $menu1item = $menu1->Append(wxID_EXIT, "Exit"); # I'm trying to set menu item icon here... # but the image does not show as expected $menu1item->SetBitmap ( $bmp ); # Creates menu bar my $menubar = Wx::MenuBar->new(); $menubar->Append($menu1, "File"); # Attach menubar to the window $frame->SetMenuBar($menubar); $frame->Show(); } MyApp->new->MainLoop;

Replies are listed 'Best First'.
Re: How do I set the menu item icon in wxPerl?
by Anonymous Monk on May 12, 2011 at 07:36 UTC
    Once you Append its too late change it
    my $item = Wx::MenuItem->new( $parent ... ); $item->SetBitmap( ... ); $parent->Append( $item );
      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: perlquestion [id://904291]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2023-02-08 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?