#!/usr/bin/perl -w use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use strict; # load all jpgs in directory for this demo my @files = <*.jpg>; #print "@files\n"; my $window = Gtk2::Window->new('toplevel'); $window->signal_connect(delete_event => sub { Gtk2->main_quit; return FALSE; }); $window->set_title("Test set up"); $window->set_border_width(0); # create your first image and pass it to $hbox my $img1 = load_first_image(); my $hbox = &make_gui_frame($img1); $window->add($hbox); Glib::Timeout->add(1000, \&update_image); $window->show; Gtk2->main; 0; sub load_first_image{ my $file = $files[0]; my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_scale($file,300,300,1); return Gtk2::Image->new_from_pixbuf($pixbuf); } sub update_image { # circular list of images just for demo push (@files,shift(@files)); my $file = $files[0]; my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_scale($file,300,300,1); $img1->set_from_pixbuf ($pixbuf); $window->show_all(); return 1; } sub make_gui_frame { my $img1 = shift; ## MAIN HBOX $hbox = Gtk2::HBox->new(FALSE, 20); my $frame = Gtk2::Frame->new('Data control'); $frame->set_shadow_type ('out'); #method of Gtk2::Container $frame->set_border_width(5); my $box1 = Gtk2::VBox->new(FALSE, 10); my $box2 = Gtk2::VBox->new(FALSE, 10); $box2->set_border_width(10); $box1->pack_start($box2, TRUE, TRUE, 0); my $button = Gtk2::Button->new("close"); $button->signal_connect(clicked => sub { Gtk2->main_quit; }); $box2->pack_start($button, TRUE, TRUE, 0); $button->can_default(TRUE); $frame->add($box1); $hbox->pack_start($frame, FALSE, FALSE,0); $frame = Gtk2::Frame->new('Data output and Overlay'); $frame->set_shadow_type ('out'); #method of Gtk2::Container $frame->set_border_width(5); my $vbox_image = Gtk2::VBox->new(FALSE, 10); $vbox_image->pack_start($img1,FALSE,FALSE,0); $frame->add($vbox_image); $hbox->pack_start($frame, FALSE, FALSE,0); $hbox->show_all(); return $hbox; }