HelenCr has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to incorporate some image showing, using wxPerl. I am getting errors trying to display images. Please see the following code excerpt:
# Image test - image manipulation use strict; use warnings; use 5.014; package MyForm; # ----------------------------------------- packag +e MyForm:: use strict; use warnings; use Wx qw[:everything]; use Wx::Event qw(EVT_BUTTON ); use parent -norequire, 'Wx::Frame'; use Wx qw(:id :toolbar :statictext wxNullBitmap wxDefaultPosition wxDe +faultSize wxNullBitmap wxTB_VERTICAL wxSIZE wxBITMAP_TYPE_ANY wxBITMAP_TY +PE_BMP); sub new { #1 --------------------------- new MyForm:: my $class = shift; my %parms = @_; my $self = $class->SUPER::new( undef, -1, 'Image test', wxDefaultPosition, # position wxDefaultSize, # size ); my ( $img, $sb, $sizer); my $panel = Wx::Panel->new( $self, -1, # parent window, ID wxDefaultPosition, wxDefaultSize); $panel->SetBackgroundColour(Wx::Colour->new('light blue')); my $welcome = Wx::StaticText->new($panel, -1, 'Welcome to Image test', + [150, 250], [-1, -1], wxALIGN_CENTER); $sizer = Wx::BoxSizer->new(wxVERTICAL); $img = Wx::Image->new($parms{image_fname}, wxBITMAP_TYPE_ANY); $sb = Wx::StaticBitmap->new($panel, -1, Wx::BitmapFromImage->new($img) +); $sizer->Add( $welcome, 0, wxALL | wxEXPAND, 5 ); $sizer->Add( $sb, 0, wxALL | wxEXPAND, 5 ); $panel->SetSizer($sizer); $panel->Fit; return $self; } #1 end sub new MyForm:: 1; # end package MyForm package main; # ----------------------------- package main +:: use strict; use warnings; use 5.014; my $image_file = 'D:\My Documents\Media\Photography\IMG_8053.JPG'; my $app = Wx::SimpleApp->new; my $frame = MyForm->new( image_fname => $image_file); $frame->Show(1); $app->MainLoop; 1;
The program fails with:
Can't locate object method "new" via package "Wx::BitmapFromImage" (perhaps you forgot to load "Wx::BitmapFromImage"?) at image test.pl line 32.Is BitmapFromImage implemented in wxPerl?
What am I missing?
Many TIA - Helen
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: wxPerl: is BitmapFromImage implemented?
by hdb (Monsignor) on Apr 28, 2013 at 14:55 UTC | |
|
Re: wxPerl: is BitmapFromImage implemented?
by jmlynesjr (Deacon) on Apr 28, 2013 at 22:20 UTC | |
by HelenCr (Monk) on Apr 28, 2013 at 23:56 UTC | |
by jmlynesjr (Deacon) on Apr 29, 2013 at 15:09 UTC | |
|
Re: wxPerl: is BitmapFromImage implemented? (no;sleep;docs)
by Anonymous Monk on Apr 29, 2013 at 08:26 UTC |