Skip to content

Instantly share code, notes, and snippets.

@chankeypathak
Created January 6, 2015 05:13
Show Gist options
  • Save chankeypathak/029569a272edb84f65d2 to your computer and use it in GitHub Desktop.
Save chankeypathak/029569a272edb84f65d2 to your computer and use it in GitHub Desktop.
Image viewer in Perl GTK2
#!/usr/bin/perl
use strict;
use warnings;
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';
my $window=Gtk2::Window->new();
$window->set_title("Image Resizer");
$window->signal_connect('delete_event',sub{Gtk2::main_quit;});
my $vbox1=Gtk2::VBox->new;
my $label=Gtk2::Label->new("Image Filename: ");
my $entry=Gtk2::Entry->new;
my $button=Gtk2::Button->new("Submit");
$button->signal_connect(clicked=>sub{
my $string=$entry->get_text;
my $label1=Gtk2::Label->new("$string");
$vbox1->add($label1);
my $pbuf=Gtk2::Gdk::Pixbuf->new_from_file_at_size("$string", 200, 200);
my $image=Gtk2::Image->new_from_pixbuf($pbuf);
$vbox1->add($image);
$window->show_all;
});
$vbox1->add($label);
$vbox1->add($entry);
$vbox1->add($button);
$window->add($vbox1);
#$window->show_all;
Gtk2->main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment