On Jun 27, 2006, at 9:27 AM, Subhrangshu Supakar wrote:

> Dear Ofey,
> I tried what you asked to do, but I got the error messege:
> *** unhandled exception in callback:
> ***   Can't locate object method "get_pixbuf" via package  
> "Gtk2::EventBox" at HPlot.pm line 232, <READ> line 6.
> ***  ignoring at HPlot.pm line 162, <READ> line 6.

It's Gtk2::Image::get_pixbuf() -- that is, a method on the Image, not  
the EventBox.


> *** unhandled exception in callback:
> ***   Can't locate object method "get_child" via package  
> "Gtk2::Ex::Graph::GD" at HPlot.pm line 230, <READ> line 6.
> ***  ignoring at HPlot.pm line 162, <READ> line 6.

Again, calling the right method on the wrong object.


Earlier, Ofey said:
>
> On 6/24/06, Subhrangshu Supakar <[EMAIL PROTECTED]> wrote:
> >  I am a newbie to Gtk2 perl, Iam not being able to save a graph  
> generated by
> > Gtk2::Ex::Graph::GD.
>
> I can tell you how to save the "image" that is being generated.
>
> The $graph->get_image($data) actually gives you a Gtk2::EventBox with
> a Gtk2::Image inside it. I took this approach because I wanted the
> graph to respond to 'events' (mouse movements etc) and the Gtk2::Image
> itself did not do that.
>
> I think what you can do is as follows.
>
> $graph = Gtk2::Ex::Graph::GD(.......);

$graph isa Gtk2::Ex::Graph::GD, which has a Gtk2::EventBox containing  
a Gtk2::Image.

> # Get the Gtk2::Eventbox out
> my $eventbox= $graph->get_image($data);

$eventbox is the EventBox...

> # Now pull the Gtk2::Image from inside the $eventbox.
> my $image = $graph->get_child;

get_child() is a Container method that you can call on the EventBox.   
This gives you the child, which is an Image.

> # Now I pull the Gtk2::Gdk::Pixbuf from inside the Gtk2::Image
> my $pixbuf = $image->get_pixbuf();

> # Now I can write that pixbuf to a file
> $pixbuf->save($filename, 'jpeg', quality => '100');

--
The door is locked.  I tried to open it, but the lock is harder to  
pick than a broken nose.
   -- Sensei, on 'I, Ninja'

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Reply via email to