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
|
use Tk;
use Tk::DirTree;
#use strict;
my($win) = MainWindow->new();
my($directory);
my($nom);
my($Texte);
my($button) = $win->Button(text => 'Choisir un répertoire',
command => \&choose_dir);
$button->pack();
MainLoop();
sub choose_dir {
my $top = $win->Toplevel();
$top->withdraw;
my $t = $top->Toplevel();
$t->title("Choose directory:");
my $ok = 0;
my $f = $t->Frame->pack(-fill => "x", -side => "bottom");
my $curr_dir="C:\\Sequest\\";
my $d;
$d = $t->Scrolled('DirTree',
-scrollbars => 'osoe',
-width => 35,
-height => 20,
-selectmode => 'browse',
-exportselection => 1,
-browsecmd => sub { $curr_dir = shift },
-command => sub { $directory = $curr_dir;
$ok = 1 },
)->pack(-fill => "both", -expand => 1);
$d->chdir($curr_dir);
$f->Button(-text => 'Ok',
-command => sub { $directory = $curr_dir;
$ok = 1 })->pack(-side => 'left');
$f->Button(-text => 'Cancel',
-command => sub { $ok = -1 })->pack(-side => 'left');
$f->waitVariable(\$ok);
if ($ok == 1) {
$top->destroy;
&lance_chaine;
}
else {
$top->destroy;
}
}
sub Relative_path {
my($name) = @_;
my($i) = rindex($name, '\\');
my($nom) = substr($name, $i+1);
return $nom;
}
sub copy {
`copy @_[0] @_[1]`;
my($xls) = @_[1]."\\interact-prot.xls";
if ( -f $xls) {
printf ("Copie du fichier interact-prot.xls dans votre répertoire %s.\n", @_[1]);
}
else {
printf ("Erreur dans la copie !\nCependant, %s est présent dans %s.\n", @_[0], @_[1]);
}
}
sub lance_chaine {
chdir $directory;
$nom = &Relative_path($directory);
$button->destroy;
$Texte = $win->Text->pack();
#Voici la ligne qui plante
#$Texte->insert("Sample", "end");
} |
Partager