j'ai un probleme j'arrive pas a reecuper les arguments de mon script lancer a partir d'un clic sur un button
voila mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::LabFrame;
use Tk::LabEntry;
use Tk::BrowseEntry;
 
my $mw = MainWindow->new(
  -title      => "bm",
  -background => 'white',
);
$mw->minsize( 500, 500 );
 
my $frame = $mw->Frame()->pack(qw/ -pady 10 -padx 10 /);
 
my ( $argument1, $argument2 );
 
my $BrowseEntry1 = $frame->BrowseEntry(
  -label    => "name : ",
  -variable => \$argument1,
  -choices  => [ "BMW-M", "BMW-S" ],
)->pack(qw/ -side left -padx 10 /);
 
my $BrowseEntry2 = $frame->BrowseEntry(
  -label    => "n : ",
  -variable => \$argument2,
  -choices  => [ "1", "2" ],
)->pack(qw/ -side right -padx 10 /);
 
$mw->Button(
  -text    => "lancer prog",
  -command => [ \&afficher, \$argument1, \$argument2 ],
)->pack();
 
MainLoop;
 
sub afficher {
  my ( $Refargument1, $Refargument2 ) = @_;
  my ( $argument1, $argument2 ) = ( ${$Refargument1}, ${$Refargument2} );
  print "Argument 1 :  : $argument1\n" if ( defined $argument1 );
  print "Argument 2 :  : $argument2\n" if ( defined $argument2 );
 print "cccccccccccccc: $argument1 gggggggggggggggg :$argument2\n";
  # Les 2 arguments sont définis
  if ( defined $argument1 and defined $argument2 ) {
    system("ppp.pl $argument1 $argument2");
  }
  else {
    warn "Les 2 arguments ne sont pas ok\n";
  }
 
  return;
}
 
 
 
 
 
#===================l'autre script ppp.perl
 
 
print "je ss :$ARGV[0] \n";
print "je ss :$ARGV[1] \n";