1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| #!C:\perl -w
use strict;
use warnings;
use Tk;
use Tk::Photo;
use Tk::PNG;
use Tk::JPEG;
use Tk::Pane;
# Programme principal
# Creation de la fenetre
my $fenetre = new MainWindow(
-title => "button image",
-background => "white",
);
my $widget_photo = $fenetre->Scrolled('Frame',
-scrollbars => 'se',
-width => 600,
-height => 600,
)->grid( );
my $MessageAccueil = "Image selection for report\n";
$fenetre->Label(
-text => $MessageAccueil,
-background => "blue",
)->grid();
my $i=1;
my $r_cnt=1;
my $c_cnt=1;
my @selected_picture;
for (1..8) {
my $ObjImage="image".$i;
my $picture="img".$i.".jpg";
$ObjImage = $widget_photo->Photo( -file => "$picture" );
my $bouton2 = $widget_photo-> Checkbutton (
-image => $ObjImage,
-command => [\&Actionbouton],
-onvalue => $picture,
-offvalue=>0,
)->grid(-row => $r_cnt,
-column =>$c_cnt,
);
$bouton2->select();
$i++;
$r_cnt++;
if ($i eq 3) {
$c_cnt++;
$r_cnt=1;
}
}
my $bt3=$fenetre->Button (
- text=>"Sortie",
-foreground => "red",
-command => sub {exit;},
)->grid();
MainLoop();
sub Actionbouton {
print "Run the action command ....\n";
print "Select\n";
} |
Partager