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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| #!/usr/local/bin/perl
use strict;
use Tk;
use Tk::DirTree;
use TK::Photo;
use TK::JPEG;
my $mw = MainWindow->new(-title=>'OUEP');
$mw->geometry("1200x1000+60+30");
# INITIALISATION DES VARIABLES
my ($lst_f, $lst_r, $elem, $retour,$repertoire, $affiche, $objet_affiche);
my(@files);
# DEFINITION DES CADRE-BOX
$lst_f = $mw->Scrolled(
"Listbox",
-scrollbars => 'e',
-background => 'white',
-foreground =>"black",
)->place( -x => 410, -y => 30, -width => 350, -height => 300, );
$lst_f->bind( "<Button-1>", \&list_select );
$lst_r = $mw->Scrolled('DirTree',-scrollbars =>'e',-directory=>"C:/Documents and Settings/xxxx/Bureau/tempo/films", ## chemin
-command=>\&repertoire)->place( -x => 30, -y => 30, -width => 350, -height => 300, );
$lst_r->configure(-background =>"lightblue", -foreground =>"#CC0063", -showhidden=>1) ;
$lst_r->Subwidget("yscrollbar")->configure(-background => "lightgreen",-troughcolor => "blue") ;
# AFFICHE LE RESUME
$mw->Label(
-textvariable => \$retour,
-justify => 'left',
-foreground => '#CC0063'
)->place( -x => 100, -y => 370, );
# AFFICHE L'AFFICHE
$objet_affiche = $mw->Photo( -file => $affiche ); ## ICI
$mw->Label( ## ICI
-image => $objet_affiche, ## ICI
)->place( -x => 780, -y => 30, ); ## ICI
sub list_select {
$elem = '';
$affiche ='';
my @select = $lst_f->curselection();
$elem = $lst_f->get( $select[0] );
$elem =~ /(.*)\.\w{3,4}/;
$elem = $1;
$affiche = $elem.".jpg"; ## ICI
$elem .= ".txt";
open IN, "<$elem" or die "$!";
while ( my $line = <IN> ) {
$retour .= $line;
}
}
sub repertoire
{
my $nd=shift;
chdir $nd;
$repertoire=$nd;
@files=() ;
$lst_f->delete(0,'end') ;
my @allfiles=() ;
opendir DH,$nd ;
@allfiles=readdir DH ;
closedir DH ;
foreach (@allfiles)
{
if(-f $_ && $_ !~ /\.(txt|pl|exe|mp3|aac|jpg|gif)/)
{
push(@files,$_) ;
$lst_f->insert('end',$_) ;
}
}
}
$mw->Button(
-text => 'Quitter',
-command => sub { $mw->destroy() },
)->place( -x => 900, -y => 900, );
MainLoop; |
Partager