help with gif in XRC file

[email protected] (RAPPAZ Francois)
Newsgroups perl.wxperl.users
Message-ID <[email protected]>
Hi
I have upgrade to a recent strawberry and the installation of Wx was painless. The errors when the main frame close are gone.

I'm now learning with Wx::Demo and I'm trying to use and XRC file to build an GUI.

I have 3 files (see below). The xrc folder has been copied from ..perl\site\lib\Wx\DemoModules\files\xrc

It contains the resource.xrc file and 5 gif files that are used in resource.xrc.

When I run my code I received the following errors

13:11:10: Unknown image data format.
13:11:10: XRC error: 21: cannot create bitmap from "fileopen.gif"
...

I'm surely missing something pretty obvious, but ...

Thanks for help

François 

My files are
./test.pl:

use strict;
use warnings;
use Xrc;
my $a = Xrc->new;
$a->app->MainLoop;

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

./Xrc.pm:

use Wx::XRC;
use strict;
use warnings;
package Xrc;

use strict;
use base qw(Wx::Panel Class::Accessor::Fast);

use Wx::Event qw(EVT_BUTTON EVT_MENU);

__PACKAGE__->mk_ro_accessors( qw(xrc app) );

sub new {
    my( $class, $parent ) = @_;
    my $self = $class->SUPER::new( $parent );

    # load XRC file
    $self->{xrc} = Wx::XmlResource->new();
    $self->xrc->InitAllHandlers();
   
    $self->xrc->Load('xrc/resource.xrc');

    $self->{app} = Wx::SimpleApp->new;
   show_frame($self);
    return $self;
}

sub show_frame {
    my( $self ) = @_;

    my $frame = Wx::Frame->new
      ( undef, -1, 'XML resources demo', [50, 50], [450, 340] );
      my $menubar = $self->xrc->LoadMenuBar( 'mainmenu' );
       my $toolbar = $self->xrc->LoadToolBar( $self, 'toolbar' );

      $frame->SetMenuBar( $menubar );
       $frame->SetToolBar( $toolbar );

    EVT_MENU( $frame, Wx::XmlResource::GetXRCID( 'menu_quit' ),
              sub { $frame->Close } );
    EVT_MENU( $frame, Wx::XmlResource::GetXRCID( 'menu_dlg1' ),
              sub { $self->show_dialog( $frame, undef ) } );

    $frame->Show;
}
1;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

./xrc/resource.xrc
<?xml version="1.0"?>
<resource>
  <object class="wxMenuBar" name="mainmenu">
    <style>wxMB_DOCKABLE</style>
    <object class="wxMenu" name="menu_file">
      <label>$File</label>
      <style>wxMENU_TEAROFF</style>
      <object class="wxMenuItem" name="menu_dlg1">
        <label>Dialog</label>
      </object>
      <object class="separator"/>
      <object class="wxMenuItem" name="menu_quit">
        <label>E$xit\tAlt-X</label>
      </object>
    </object>
  </object>
  <object class="wxToolBar" name="toolbar">
    <style>wxTB_FLAT|wxTB_DOCKABLE</style>
    <margins>2,2</margins>
    <object class="tool" name="menu_open">
	    <bitmap>fileopen.gif</bitmap>
      <tooltip>Open catalog</tooltip>
    </object>
    <object class="tool" name="menu_save">
	    <bitmap>filesave.gif</bitmap>
      <tooltip>Save catalog</tooltip>
    </object>
...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.