IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces Graphiques Perl Discussion :

aide choix BrowseEntry


Sujet :

Interfaces Graphiques Perl

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Août 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2010
    Messages : 37
    Par défaut aide choix BrowseEntry
    Bonjour a tous
    j'ai besoin de votre aide j'ai un script dans lequel j'ai des BrowseEntry avant j'utilisé l'option choix pour choisir une variable , je désire maintenant avoir ce choix a partir d'un fichier excel en cliquant sur un bouton le script ouvre un fichié excel est rempli le choix de BrowseEntry.
    je ne c'est pas si c'est possible
    voici un script qui explique mon problem

    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
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    #!/usr/bin/perl
    use strict;
    use warnings;
    use Tk;
    use Cwd;
    use Win32::OLE qw(in with);
    use Win32::OLE::Const 'Microsoft Excel';
    use Win32::OLE::Variant;
    $Win32::OLE::Warn = 1;
    require 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  => [ "$argument1" ],
    )->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 => [ \&voiture, \$argument1, \$argument2 ],
    )->pack();
     
    $mw->Button(
      -text    => "List",
      -command => [ \&liste, ],
    )->pack();
     
    MainLoop;
     
    sub voiture {
      my ( $Refargument1, $Refargument2 ) = @_;
      my ( $argument1, $argument2 ) = ( ${$Refargument1}, ${$Refargument2} );
      print "Argument 1 :  : $argument1\n" if ( defined $argument1 );
      print "Argument 2 :  : $argument2\n" if ( defined $argument2 );
      if ( defined $argument1 and defined $argument2 ) {
        system("voiture_v8.exe $argument1 $argument2");
      }
      else {
        warn "Les 2 arguments ne sont pas ok\n";
      }
      return;
    }
    sub liste {
     
         my $choix1="list.xls";
         my $argument1;
         my $cmd = getcwd;
            $cmd =~ s/\//\\/g;
         my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application');
            $Excel->{Visible} = 1;
         my $book = $Excel->Workbooks->Open("$cmd/$choix1") or die Win32::OLE->LastError;
     
         my $sheet    = $book -> Worksheets(1) -> {Name};
            $sheet    = $book -> Worksheets($sheet);
            $sheet                -> Activate;
            $sheet -> Range("A") -> {Value} = "$argument1";
     
       $book->Save();
       $Excel->Quit();
    };

  2. #2
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut
    tu peux utiliser configure sur ta variable $BrowseEntry1 et modifier les choix.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Août 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2010
    Messages : 37
    Par défaut
    Salut Djibril
    Merci pour ton aide ,j'ai pensé a une nouvelle solution plus facile est plus adapté a mon problem, mais je suis blocké sur un problem que je c'est pas résoudre ,
    c'est le meme script j'utilise cette fois "chooseDirectory " ce que j'assay de faire est quand on appuit sur ok le non du repertoire se récopie dans le la liste déroulante "name" pour ensuite excécuté lance prog
    je c'est pas si c'est realisable sinon y 'a t il une autre solution dans le meme esprit ?

    voici le script a l'etape de mon blocage

    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 strict;
    use warnings;
    use Tk;
    use Cwd;
    use Win32::OLE qw(in with);
    use Win32::OLE::Const 'Microsoft Excel';
    use Win32::OLE::Variant;
    $Win32::OLE::Warn = 1;
    require 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,
    )->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 => [ \&voiture, \$argument1, \$argument2 ],
    )->pack();
     
    $mw->Button(
      -text => "Lister des Dossier",
      -command => sub {
     
        my $Directory = $frame->chooseDirectory(
        -title      => "Selection des repertoires",
        -mustexist  => 1,
        );
      },
    )->pack();
    MainLoop;
     
    sub voiture {
      my ( $Refargument1, $Refargument2 ) = @_;
      my ( $argument1, $argument2 ) = ( ${$Refargument1}, ${$Refargument2} );
      print "Argument 1 :  : $argument1\n" if ( defined $argument1 );
      print "Argument 2 :  : $argument2\n" if ( defined $argument2 );
      if ( defined $argument1 and defined $argument2 ) {
        system("voiture_v8.exe $argument1 $argument2");
      }
      else {
        warn "Les 2 arguments ne sont pas ok\n";
      }
      return;
    }

  4. #4
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut
    Peux tu essayer d'écrire lisiblement la prochaine fois en faisant attention aux fautes d'orthographe, c'est assez désagréable à lire. De plus, s'agissant du code perl, pense à l'encadrer des balises codes la prochaine fois.

    Merci

  5. #5
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 822
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 822
    Par défaut
    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
    64
    65
    66
    67
    68
    69
    70
    71
    72
    #!/usr/bin/perl
    use strict;
    use warnings;
    use Tk;
    use Cwd;
    use Win32::OLE qw(in with);
    use Win32::OLE::Const 'Microsoft Excel';
    use Win32::OLE::Variant;
    $Win32::OLE::Warn = 1;
    require 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,
    )->pack(qw/ -side left -padx 10 /);
     
    my $BrowseEntry2 = $frame->BrowseEntry(
      -label    => "n : ",
      -variable => \$argument2,
      -choices  => [ "1", "2" ],
    )->pack(qw/ -side right -padx 10 /);
     
    my $BoutonLancementProg = $mw->Button(
      -text    => "lancer prog",
      -command => [ \&voiture, \$argument1, \$argument2 ],
    )->pack();
     
    $mw->Button(
      -text    => "Lister des Dossier",
      -command => sub {
     
        # Ouverture du répertoire
        my $Directory = $frame->chooseDirectory(
          -title     => "Selection des repertoires",
          -mustexist => 1,
        );
        return unless defined $Directory;
     
        # On conserve le nom du répertoire dans $argument1
        $argument1 = $Directory;
     
        # On simule le clic sur le bouton "lancer prog"
        $BoutonLancementProg->invoke;
     
      },
    )->pack();
     
    MainLoop;
     
    sub voiture {
      my ( $Refargument1, $Refargument2 ) = @_;
      my ( $argument1, $argument2 ) = ( ${$Refargument1}, ${$Refargument2} );
      print "Argument 1 :  : $argument1\n" if ( defined $argument1 );
      print "Argument 2 :  : $argument2\n" if ( defined $argument2 );
      if ( defined $argument1 and defined $argument2 ) {
        system("voiture_v8.exe $argument1 $argument2");
      }
      else {
        warn "Les 2 arguments ne sont pas ok\n";
      }
      return;
    }

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Août 2010
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2010
    Messages : 37
    Par défaut
    Merci Bien Djibril pour l’aide,
    Ca fonctionne Bien j’ai rajouté quelque ligne de code pour récupéré que le dossier sélectionné :

    my @arg = split("/", $Directory );

    $argument1 = @arg[$#arg];

    Ca fonctionne très bien. Mais j’ai un message d’erreur du style :

    Scalar value @arg[$#arg] better written as $arg[$#arg] at …

    Comment peut on résoudre ce problème

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Aide choix technologie - application serveur
    Par aure298 dans le forum Plateformes (Java EE, Jakarta EE, Spring) et Serveurs
    Réponses: 8
    Dernier message: 31/07/2009, 12h47
  2. aide choix language
    Par flipracing dans le forum Langages de programmation
    Réponses: 6
    Dernier message: 25/01/2009, 23h15
  3. Besoin d'aide choix base de données
    Par dubidon dans le forum Décisions SGBD
    Réponses: 3
    Dernier message: 06/08/2008, 12h46
  4. Aide choix NAS
    Par stygre dans le forum Périphériques
    Réponses: 4
    Dernier message: 26/05/2008, 19h10
  5. aide choix vue (framework) pour struts
    Par gibson700 dans le forum Struts 1
    Réponses: 4
    Dernier message: 16/03/2007, 10h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo