Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

I'm getting "unable to resolve overloaded method for "Wx::RichTextCtrl::WriteImage" at /home/steve/Documents/Endoscopia/RichText_Editor.pl line 506" from code:

sub on_click_insert_image{ my ($i_frame, $event) = @_; my $file = Wx::FileSelector('Choose a media file'); + # Select video file $i_frame->{Ctl_Report_Text_Txt}->WriteImage(Wx::Image->new($file, +wxBITMAP_TYPE_PNG)); return $i_frame; }

But the same code with:

" $i_frame->{Ctl_Report_Text_Txt}->AddImage(Wx::Image->new($file, wxBI +TMAP_TYPE_PNG)); "

Works fine (but appends, rather than inserting the image). Does anyone know the correct syntax for WriteImage to insert an image at the current insertion point?

Update:OK, here's the answer:

" $i_frame->{Ctl_Report_Text_Txt}->WriteImageImage(Wx::Image->new($fil +e, wxBITMAP_TYPE_PNG)); "

Works fine too! Not quite sure about that naming convention!

Have a good day.

Regards

Steve

Replies are listed 'Best First'.
Re: unable to resolve overloaded method for "Wx::RichTextCtrl::WriteImage"
by Anonymous Monk on Jan 28, 2010 at 19:33 UTC
    Something must have gone wrong when building Wx ... it doesn't work in Wx 0.95, but works in Wx-0.96

    http://search.cpan.org/grep?cpanid=MBARBON&release=Wx-0.96&string=WriteImage&i=1&n=1&C=0

    459: %name{WriteImageFile} bool WriteImage( const wxString& filenam +e, 461: %name{WriteImageBitmap} bool WriteImage( const wxBitmap& bitma +p, 463: %name{WriteImageImage} bool WriteImage( const wxImage& image, 712:WriteImage( ... ) 715: MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wimg_n, WriteImageI +mage, 1 ) 716: MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wbmp_n, WriteImageB +itmap, 1 ) 717: MATCH_REDISP( wxPliOvl_s_n, WriteImageFile ) 718: END_OVERLOAD( "Wx::RichTextCtrl::WriteImage" )
    #!/usr/bin/perl -- use strict; use warnings; use Wx; use Wx::RichText; my $png = shift(@ARGV) || 'camel.favicon.png'; my $rtc = Wx::RichTextCtrl->new; my $img = Wx::Image->new( $png, Wx::wxBITMAP_TYPE_ANY() ); my $bmp = Wx::Bitmap->new( $png, Wx::wxBITMAP_TYPE_ANY() ); my $ico = Wx::GetWxPerlIcon(); for my $i ( $png, $img, $bmp, $ico ) { printf "%03d %s\n %s\n\n", __LINE__, $i, eval { $rtc->WriteImage($i); 1 } || $@; } printf "%03d %s\n %s\n\n", __LINE__, $png, eval { $rtc->WriteImage( $png, Wx::wxBITMAP_TYPE_ANY() ); 1 } || $@; printf "$_\n" for grep /image/i, keys %Wx::RichTextCtrl::; __END__ 016 camel.favicon.png unable to resolve overloaded method for "Wx::RichTextCtrl::WriteImage +" at 2 line 17 eval {...} called at 2 line 17 016 Wx::Image=SCALAR(0x9ff81c) 1 016 Wx::Bitmap=SCALAR(0xd53534) 1 016 Wx::Icon=SCALAR(0x9ffabc) unable to resolve overloaded method for "Wx::RichTextCtrl::WriteImage +" at 2 line 17 eval {...} called at 2 line 17 020 camel.favicon.png 1 WriteImageImage AddImage WriteImageFile WriteImageBitmap WriteImage