Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

How do I set the menu item icon in wxPerl?

by ZJ.Mike.2009 (Scribe)
on May 12, 2011 at 04:03 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-18 00:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found