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
| #!/usr/bin/perl -w
use Tk;
#Paramètres d'entrée
$depart="";# depart_boucle
$fin="";#fin_boucle
#++++++++++++++++++++
#Programme Principal
#++++++++++++++++++++
$fen=MainWindow->new(-title=>HP_SCAN);
$texte=$fen->Label(-textvariable=>\$val)->pack;
$texte->Label(-text=>"Problème-Aide")->pack;
$val=1;
#Creation d'une liste
$lb=$fen->Listbox()->pack;
$lb->insert(0," WWW");
$lb->insert(1," DEVELOPPEZ");
$lb->insert(2," COM");
#Creation de 2 cadres
#Cadre1
$frame1=$fen->Frame()->pack(-fill=>'both');
$case1=$frame1->Label(-text=>"Depart")->pack(-side=>"top",-fill=>'x');
$case1->Entry(-textvariable=>\$depart,-width=>5)->pack(-side=>"right");
$case2=$frame1->Label(-text=>"Fin")->pack(-side=>"bottom",-fill=>'x');
$case2->Entry(-textvariable=>\$fin,-width=>5)->pack(-side=>"right");
#Cadre2
$frame2=$fen->Frame()->pack;
$frame2->Button(-text=>"Start",-command=>\&HP)->pack(-fill=>'x',-side=>"left");
$frame2->Button(-text=>"Stop",-command=>\&SP)->pack(-fill=>'x',-side=>"left");
$frame2->Button(-text=>"Cancel",-command=>sub{exit})->pack(-fill=>'x',-side=>"left");
MainLoop;
sub SP{print "OK Merci\n";}
sub HP{for($index=$depart;$index<=$fin;$index++)
{print "C'est un test!\n";
@tab=(2..4);
sleep $tab[rand@tab];
}
} |
Partager