#!/usr/bin/perl -w use strict; use Tk; use Tk::WinPhoto; use Tk::JPEG; use Tk::Pane; my $mw = MainWindow->new(); $mw->minsize(qw(670 510)); $mw->configure(-background=>'gray'); $mw->title("Screen Capture GUI"); my $img_count = 0; my $but_capture = $mw->Button( -text => "Capture Screen", -command => sub { \&Grab() } ); $but_capture -> place(-x=>10,-y=>5, -width=>650); my $exit = $mw->Button( -text => "Exit", -command => sub { exit } ); $exit -> place(-x=>560,-y=>460, -width=>100); my $frame2_1 = $mw->Scrolled(qw/Pane -scrollbars ose/); $frame2_1 -> place(-x=>10,-y=>50, -width=>650, -height=>400 ); MainLoop(); sub Grab(){ ########################################################################## #Creating file handle and taking picture my $tim = time(); my $fname = "/tmp/".$tim.".jpg"; print "$fname\n"; system("import -frame $fname"); #resize to display in window my $fname2=$fname."sm.jpg"; system("convert -size 350X350 $fname -resize 350x350 $fname2"); ########################################################################## $img_count++; my $mini; #Frame packed in scrolling Pane $mini = $frame2_1->Frame(-background=>'#3300ff')->pack(-anchor => 'w', -fill =>"x"); #create new frame to hold new image contents my $img_label = $mini->Label(-text=>"Image $img_count"); $img_label ->pack(); my $pic_location = $mini->Label(-text=>"Pathname:"); $pic_location ->pack(); my $pic_fname = $mini->Entry(-width=>50,-textvariable=>"$fname"); $pic_fname ->pack(); my $pic = $mini->Photo( -file =>"$fname2"); my $f =$mini->Label(-image => $pic); $f ->pack(); my $but_delete = $mini ->Button( -text => "Delete Image", -command => sub { \&Delete($mini) } ); $but_delete -> pack(); my $blank1 = $frame2_1->Label(-text=>""); $blank1 ->pack(); } sub Delete(){ my $fn =@_; $fn ->destroy; }