Re: a bunch of questions about displaying jpegs



1. How do I change the picture to another one?  The only way I
   succeeded in doing that was by destroying the frame and adding a
   new frame.  But that is not very elegant and also not feasible when
   the picture is somewhere deeply nested in widgets.

Use the child() method of the frame widget to remove the image, and then
add your new one. eg:

$frame->remove($frame->child);
$frame->add($new_image);

2. Is it better to use pixbuf instead of Imlib?  How does that work?

3. Is it better to use gtk2 instead of gtk?  At this moment I only
   care about getting the "job" done.  Finding documentation has been
   a little harder than I imagined.

Gtk+ 2 uses GdkPixbuf throughout and you'll find it a *lot* better for
handling graphics. Instead of 

my $im = load_image Gtk::Gdk::ImlibImage($file);
    my $w = $im->rgb_width;
    my $h = $im->rgb_height;
    $im->render($w, $h);
    my $p = $im->move_image();
    my $m = $im->move_mask;
    $pixmapwid = new Gtk::Pixmap( $p, $m );

you do

my $image = Gtk2::Image->new_from_file($file);

if you need to manipulate the image create a pixbuf:

my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($file);

and then when you're done:

my $image = Gtk2::Image->new_from_pixbuf($pixbuf);

4. How do I find out about all the methods that $pixmapwid (for
   instance) responds to.  I have been trying random names without
   much luck and I'm feeling quite stupid.

Consult the Gtk documentation on developer.gnome.org for a full list of
all the methods. The Perl libraries correspond as closely as possible to
the C libraries.

Gavin.

-- 
Gavin Brown
e: gavin brown uk com
w: http://jodrell.net/
PGP/GPG key ID: 891D8FCA

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]