In order to port some of my image viewing tools from Perl::Tk to
the Perl-GnomeCanvas I need to be able to show images on the
canvas. But appearently this functionality is broken in Gtk-Perl-0.6123 .
My guess from looking at the source in the CVS version is that it
doesn't work there either. I have created an example below, which
shows the problem. To test it just run the script. The fact foo.ppm
doesn't exist is irrelavent to the failure which is:
  
   Cannot set argument of type GdkImlibImage (fundamental type GtkBoxed)
   at ./img-on-canvas line 42.

Does anyone (which probably includes only Kenneth or Paolo) have any
idea of what is going on?

Regards,
Dov

Example included:

#!/usr/local/bin/perl
######################################################################
#  This file should be an example of how to put an imlib image
#  on the canvas.
#
#  Unfortunately it doesn't work.
#
#  Dov Grobgeld
#  5 Dec 1999
######################################################################
use Gtk;
use Gnome;

my ($canvas_width, $canvas_height) = (300,300);

init Gnome "img on canvas";

# Create main window
my $mw = Gtk::Widget->new("GtkWindow",
                          -type                 => -toplevel,
                          -title                => "Img on Canvas",
                          -signal::destroy => sub {exit}
                         );
    
# Create a canvas
my $canvas = Gnome::Canvas->new();
show $canvas;
$canvas->set_usize($canvas_width,$canvas_height);
$canvas->set_scroll_region (0, 0, $canvas_width, $canvas_height);
$mw->add($canvas);

# Create some objects on the canvas
$root = $canvas->root();

# Create a rectangle on the canvas
Gnome::CanvasItem->new($root, "Gnome::CanvasRect",
                       "x1", 30,
                       "y1", 30,
                       "x2", 80,
                       "y2", 50,
                       "width_pixels", 1,
                       "fill_color", "red",
                       "outline_color"=>"black",
                      );

# Create an image on the canvas
$img = Gtk::Gdk::ImlibImage->load_image("foo.ppm");
Gnome::CanvasItem->new($root,
                       "Gnome::CanvasImage",
                       "image", $img,
                       "x", 100,
                       "y", 100,
                      );

$mw->show;

main Gtk;

-- 
To unsubscribe: mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to