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 :

liste déroulante et affichage


Sujet :

Interfaces Graphiques Perl

  1. #1
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut liste déroulante et affichage
    Bonjour,

    J'arrive pas à passer au-dessus de ce problème :
    j'ai un tableau dans un sub qui renvoit @champs

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    while ( my $line = <IN> ) {
      if ( $line =~ /^Edition\tPublication/ ) {
        @champs = split (/\t/, $line);
        }
    } 
    }

    ici je récupère du sub @champs pour avoir une liste des élèments.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    # AFFICHE LES CHAMPS DU FICHIER
    $fenetre_principale->BrowseEntry(
      -label => \$champs[0],
      -choices => [\@champs],
      -variable => \$mon_choix,
    )->pack(qw/ -side left/);
    Mon problème est que j'ai tous les élèments les uns à côté des autres et non pas les uns en dessous des autres... et ainsi sélectionner celui dont j'ai besoin...

    voilà, si qq un pouvait m'aider...ça serait cool
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  2. #2
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    -choices => \@champs,

  3. #3
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    J'avais essayé et refais maintenant mais ça me rend une liste vide...
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  4. #4
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Faut le programme complet car là, on ne sait pas comment tu t'y prends.
    si au moment de la cration du widget le tableau est vide, c normal

  5. #5
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    Voilà la bête :

    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
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
     
    #!/usr/local/bin/perl
     
    use strict;
    use warnings;
    use Tk;
    use Tk::BrowseEntry;
    use Tk::DirTree;
    use Spreadsheet::WriteExcel;
     
    my $fenetre_principale = MainWindow->new(-title=>'Journaux d\'inventaire', -background => '#4A44F7',);
    $fenetre_principale->geometry("1000x600+60+30");
     
    my ($mon_choix, $retour, $nd, $repertoire, $resume, $elem, $line, $select, $champs, $lst_f, $listeRepertoire);
    my (@files, @allfiles, @select, @champs);
    my ($choixUn, $choixDeux);
    # DEFINITION DES CADRES-BOX
    $lst_f = $fenetre_principale->Scrolled(
      "Listbox",
      -scrollbars => 'e',
      -background => 'white',
      -foreground =>"black",
    )->place( -x => 410, -y => 30, -width => 350, -height => 300, );
     
    $lst_f->bind( "<Button-1>", \&Colonnes );
     
    $listeRepertoire  = $fenetre_principale->Scrolled('DirTree',-scrollbars =>'e',-directory=>"C:/Users/xxx/Desktop/",
        -command=>\&repertoire)->place( -x => 30, -y => 30, -width => 350, -height => 300, );
    $listeRepertoire->configure(-background =>"lightblue", -foreground =>"#CC0063", -showhidden=>1) ;
    $listeRepertoire->Subwidget("yscrollbar")->configure(-background => "lightgreen",-troughcolor => "blue") ;
     
    # AFFICHE LES CHAMPS DU FICHIER
    $fenetre_principale->BrowseEntry(
      -label => 'champsUn',
      -choices=> \@champs,
      -variable => \$choixUn,
    )->pack(qw/ -side left/);
     
    $fenetre_principale->BrowseEntry(
      -label => 'champsDeux',
      -choices=> \@champs,
      -variable => \$choixDeux,
    )->pack(qw/ -side left/);
     
    sub Colonnes {
      my @select = $lst_f->curselection();
      my $elem = $lst_f -> get( $select[0] );
     
      open IN, "<$elem" or die "$!";
     
      while ( my $line = <IN> ) {
        if ( $line =~ /^Edition\tPublication/ ) {
          @champs = split (/\t/, $line);
          }
      } # while
    } # sub
     
    # bouton action
    my $BoutonGO = $fenetre_principale->Button(
      -text    => "Générer le fichier",
      -command => [\&go, \$mon_choix],   # code pas à jour...
    )->pack(qw/ -side left/); # -padx 100 -pady 450
     
     
    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 $_ && $_ =~ /\.utx/){
          push(@files,$_) ;
          $lst_f->insert('end',$_) ;
          }
        }
    }
     
    #sub go {
    #  my ($ref_choix) = @_;
    #  my $choix = ${$ref_choix};
    #  if ( $choix eq 'Communication' ) { sub_Communication($fenetre_principale); }
    #  elsif ( $choix eq 'Acquisitions' ) { sub_Acquisitions($fenetre_principale); }
    #  }
     
    $fenetre_principale->Button(
      -text    => 'Quitter',
      -command => sub { $fenetre_principale->destroy() },
    )->place( -x => 900, -y => 100, );
     
    MainLoop;
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  6. #6
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    sans lire le code, faut éviter ce genre de chose : déclarations d'une variable $champs et @champs (même nom) corrige déjà ça.

  7. #7
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    FAIT !
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  8. #8
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    et ton prog, il est où ?

  9. #9
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    dans le mm dossier que le fichier que je sélectionne.

    Pour info de cette manière [\@champs] j'ai une liste horizontale
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  10. #10
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    impossible de les faire apparaitre autrement :

    Nom : Capture.PNG
Affichages : 60
Taille : 2,4 Ko
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  11. #11
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Je te demandais le prog final

  12. #12
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    ? il restera sur mon pc si cêst la réponse à ta question..
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  13. #13
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Je veux le voir pour pouvoir voir ce qui ne vas pas

  14. #14
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    je comprend pas bien... le programme a été posté hier à 16h39...


    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  15. #15
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Mais dans celui de 16h39, il n'y a pas les corrections que je t'avais demandé de faire par rapport aux noms des variables !

  16. #16
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    C'est pas 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
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
     
    #!/usr/local/bin/perl
     
    use strict;
    use warnings;
    use Tk;
    use Tk::BrowseEntry;
    use Tk::DirTree;
    use Spreadsheet::WriteExcel;
     
    my $fenetre_principale = MainWindow->new(-title=>'Journaux d\'inventaire', -background => '#4A44F7',);
    $fenetre_principale->geometry("1250x600+10+60");
     
    my ($mon_choix, $retour, $nd, $repertoire, $resume, $elem, $line, $lst_f, $listeRepertoire);
    my (@files, @allfiles, @select, @champs);
    my ($choix1, $choix2)
     
    # DEFINITION DES CADRES-BOX
    $lst_f = $fenetre_principale->Scrolled(
      "Listbox",
      -scrollbars => 'e',
      -background => 'white',
      -foreground =>"black",
    )->place( -x => 410, -y => 30, -width => 350, -height => 200, );
     
    $lst_f->bind( "<Button-1>", \&Colonnes );
     
    $listeRepertoire  = $fenetre_principale->Scrolled('DirTree',-scrollbars =>'e',-directory=>"C:/Users/xxx/Desktop/stock/",
        -command=>\&repertoire)->place( -x => 30, -y => 30, -width => 350, -height => 200, );
    $listeRepertoire->configure(-background =>"lightblue", -foreground =>"#CC0063", -showhidden=>1) ;
    $listeRepertoire->Subwidget("yscrollbar")->configure(-background => "lightgreen",-troughcolor => "blue") ;
     
     
    $fenetre_principale->BrowseEntry(
      -label => ' 1 ',
      -choices=> \@champs,
      -variable => \$choix1,
    )->place( -x => 0, -y => 235);
    $fenetre_principale->BrowseEntry(
      -label => ' 2 ',
      -choices=> [\@champs],
      -variable => \$choix2,
    )->place( -x => 170, -y => 235);
     
     
    sub Colonnes {
      my @select = $lst_f->curselection();
      my $elem = $lst_f -> get( $select[0] );
     
      open IN, "<$elem" or die "$!";
     
      while ( my $line = <IN> ) {
      chomp $line;
        if ( $line =~ /^Edition\tPublication/ ) {
          @champs = split (/\t/, $line);
          }
        #
      } # while
    } # sub
     
    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 $_ && $_ =~ /\.utx/){
          push(@files,$_) ;
          $lst_f->insert('end',$_) ;
          }
        }
    }
     
    sub go {
     my ($ref_choix) = @_;
     my $choix = ${$ref_choix};
      if ( $choix eq 'Communication' ) { sub_Communication($fenetre_principale); }
      #elsif ( $choix eq 'Acquisitions' ) { sub_Acquisitions($fenetre_principale); }
      }
     
    $fenetre_principale->Button(
      -text    => 'Quitter',
      -command => sub { $fenetre_principale->destroy() },
    )->place( -x => 900, -y => 100, );
     
    MainLoop;
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  17. #17
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Il faudrait aussi un fichier d'exemple pour pouvoir tester ton programme.

  18. #18
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    test.txt

    Le fichier est normalement au format utx mais je peux pas le charger
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  19. #19
    Membre habitué Avatar de PadawanInPerl
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    462
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juillet 2009
    Messages : 462
    Points : 186
    Points
    186
    Par défaut
    Bonjour,

    Pour information si ça peut aider quelqu'un, j'ai fais cela pour avoir les données les unes après les autres et non pas en ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
      -choices=> [\@champs],
    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
     
    @champs = split (/\t/, $line);
          foreach my $champs(@champs){
            $choix1 -> insert ("end", $champs);
            $choix2 -> insert ("end", $champs);
            $choix3 -> insert ("end", $champs);
            $choix4 -> insert ("end", $champs);
            $choix5 -> insert ("end", $champs);
            $choix6 -> insert ("end", $champs);
            $choix7 -> insert ("end", $champs);
            $choix8 -> insert ("end", $champs);
            $choix9 -> insert ("end", $champs);
            $choix10 -> insert ("end", $champs);
            $choix11 -> insert ("end", $champs);
            $choix12 -> insert ("end", $champs);
            $choix13 -> insert ("end", $champs);
            $choix14 -> insert ("end", $champs);
            $choix15 -> insert ("end", $champs);
            $choix16 -> insert ("end", $champs);
            $choix17 -> insert ("end", $champs);
            $choix18 -> insert ("end", $champs);
            $choix19 -> insert ("end", $champs);
            $choix20 -> insert ("end", $champs);
            }  #foreach
    J'aurais aimé faire quelque chose de dynamique du genre (GNUVince) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    {
        no strict 'vars';
        ${"choix$i"}  -> insert ("end", $champs);
    }
    Mais ça n'a pas marché.

    Tant pis, au moins j'ai mon résultat.
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  20. #20
    Responsable Perl et Outils

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 499 184
    Points
    499 184
    Par défaut
    Il faudrait expliquer clairement le but de ton programme car même en le récupérant, rien n'est clair.
    Qu'est-ce qu'il est censé faire, quelles sont les actions que tu attends de ton programme...

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Réponses: 1
    Dernier message: 13/08/2008, 17h06
  2. [SQL] Liste déroulante et affichage
    Par sara2001 dans le forum PHP & Base de données
    Réponses: 5
    Dernier message: 11/07/2007, 11h44
  3. [Tableaux] Pb Liste déroulante + Pb affichage
    Par mikacontact dans le forum Langage
    Réponses: 5
    Dernier message: 08/12/2006, 16h52
  4. Sélection liste déroulante puis affichage de text box
    Par dolu007 dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 11/11/2006, 00h03
  5. Lien en entre listes déroulantes et affichage d'Etat
    Par Sofie109 dans le forum Access
    Réponses: 3
    Dernier message: 08/09/2006, 15h08

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