re: display/update a jpeg image?
- From: "Chas Owens" <chas owens gmail com>
- To: gtk-perl-list gnome org
- Subject: re: display/update a jpeg image?
- Date: Tue, 19 Dec 2006 18:56:57 -0500
---------- Forwarded message ----------
From: Chas Owens <chas owens gmail com>
Date: Dec 19, 2006 6:56 PM
Subject: Re: display/update a jpeg image?
To: Colin Anderson <canderson minotstateu edu>
I am trying to make a simple image viewer application. My script reads in the file names
from a directory of .jpg images and uses these names to fill a List widget.
I would like to display the first image in the list by default and have that image
updated/replaced every time another image is selected from the List widget. How do I go
about doing this? Is there some sample code I could reference? I have done some
searching in the tutorials and docs, but can only find very basic pixmap examples.
TIA
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2;
use Gtk2::Ex::Simple::List;
Gtk2->init;
my $w = Gtk2::Window->new;
my $hpaned = Gtk2::HPaned->new;
my $sw = Gtk2::ScrolledWindow->new;
my $list = Gtk2::Ex::Simple::List->new('filename' => 'text');
my $img = Gtk2::Image->new_from_file($ARGV[0]);
$w->add($hpaned);
$hpaned->add1($sw);
$sw->add($list);
$hpaned->add2($img);
@{$list->{data}} = @ARGV;
$list->signal_connect('cursor_changed' => sub {
my $list = shift;
my ($model, $iter) = $list->get_selection->get_selected;
$img->set_from_file($model->get_value($iter, 0));
});
$sw->set_policy('automatic', 'automatic');
$hpaned->set_position(200);
$w->signal_connect('destroy', sub { Gtk2->main_quit });
$w->set_default_size(640, 480);
$w->show_all;
Gtk2->main;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]