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. #21
    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 des listes déroulantes où mes données étaient comme cela :
    un deux trois

    alors que je les voulais comme cela :
    un
    deux
    trois

    comme mon 1er post et ton premier je pensais que ça aller marcher. mais non.j'ai dû faire un insert.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    @champs = split (/\t/, $line);
          foreach my $champs(@champs){
            $choix1 -> insert ("end", $champs);
            $choix2 -> insert ("end", $champs);
    c'est ce code qui m'a permis de mettre les données les unes en desous des autres.

    c'est donc réglé...

    mais je reviendrais sûrement pour autre chose...
    Windows 7, 64 bit
    Perl 5.12, ActivePerl
    Python 3.2, ActivePython ( NOVICE ! )

  2. #22
    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
    Peux-tu remettre ton code en entier. Je n'ai pas l'impression qu'il soit très bien écrit, même s'il semble fonctionner.

  3. #23
    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
    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
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
     
    #!/usr/local/bin/perl
     
    # besoin de la première ligne pour générer les en-tete de colonne
    #
    #
    # pas d'accent dans les titres !
    #
    #
    #
    use diagnostics;
    use strict;
    use warnings;
    use Tk;
    use Tk::BrowseEntry;
    use Tk::DirTree;
    use Spreadsheet::WriteExcel;
     
     
    #############################################################
    ##################################### PARTIE création fenêtre
    #############################################################
    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, @tab, @totalChoix);
    my ($choix1, $choix2, $choix3, $choix4, $choix5, $choix6, $choix7, $choix8, $choix9, $choix10);
    my ($choix11, $choix12, $choix13, $choix14, $choix15, $choix16, $choix17, $choix18, $choix19, $choix20);
    my ($var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8, $var9, $var10);
    my ($var11, $var12, $var13, $var14, $var15, $var16, $var17, $var18, $var19, $var20);
     
    # 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") ;
     
     
    ##############################################DEBUT CHOICES
    ######### box selection 1ere ligne
    $choix1 = $fenetre_principale->BrowseEntry(
      -label => ' 1 ',
      -choices=> \@champs,
      -variable => \$var1,
    )->place( -x => 0, -y => 235);
    $choix2 = $fenetre_principale->BrowseEntry(
      -label => ' 2 ',
      -choices=> \@champs,
      -variable => \$var2,
    )->place( -x => 170, -y => 235);
    $choix3 = $fenetre_principale->BrowseEntry(
      -label => ' 3 ',
      -choices=> \@champs,
        -variable => \$var3,
    )->place( -x => 340, -y => 235);
    $choix4 = $fenetre_principale->BrowseEntry(
      -label => ' 4 ',
      -choices=> \@champs,
        -variable => \$var4,
    )->place( -x => 510, -y => 235);
    $choix5 = $fenetre_principale->BrowseEntry(
      -label => ' 5 ',
      -choices=> \@champs,
        -variable => \$var5,
    )->place( -x => 680, -y => 235);
    $choix6 = $fenetre_principale->BrowseEntry(
      -label => ' 6 ',
      -choices=> \@champs,
        -variable => \$var6,
    )->place( -x => 850, -y => 235);
    $choix7 = $fenetre_principale->BrowseEntry(
      -label => ' 7 ',
      -choices=> \@champs,
        -variable => \$var7,
    )->place( -x => 1020, -y => 235);
    ###############################
    ######## box selection 2è ligne
    $choix8 = $fenetre_principale->BrowseEntry(
      -label => ' 8 ',
      -choices=> \@champs,
        -variable => \$var8,
    )->place( -x => 0, -y => 265);
    $choix9 = $fenetre_principale->BrowseEntry(
      -label => ' 9 ',
      -choices=> \@champs,
        -variable => \$var9,
    )->place( -x => 170, -y => 265);
    $choix10 = $fenetre_principale->BrowseEntry(
      -label => ' 10 ',
      -choices=> \@champs,
        -variable => \$var10,
    )->place( -x => 340, -y => 265);
    $choix11 = $fenetre_principale->BrowseEntry(
      -label => ' 11 ',
      -choices=> \@champs,
        -variable => \$var11,
    )->place( -x => 510, -y => 265);
    $choix12 = $fenetre_principale->BrowseEntry(
      -label => ' 12 ',
      -choices=> \@champs,
        -variable => \$var12,
    )->place( -x => 680, -y => 265);
    $choix13 = $fenetre_principale->BrowseEntry(
      -label => ' 13 ',
      -choices=> \@champs,
        -variable => \$var13,
    )->place( -x => 850, -y => 265);
    $choix14 = $fenetre_principale->BrowseEntry(
      -label => ' 14 ',
      -choices=> \@champs,
        -variable => \$var14,
    )->place( -x => 1020, -y => 265);
    ##################################
    ########### box selection 3è ligne
    $choix15 = $fenetre_principale->BrowseEntry(
      -label => ' 15 ',
      -choices=> \@champs,
        -variable => \$var15,
    )->place( -x => 0, -y => 295);
    $choix16 = $fenetre_principale->BrowseEntry(
      -label => ' 16 ',
      -choices=> \@champs,
        -variable => \$var16,
    )->place( -x => 170, -y => 295);
    $choix17 = $fenetre_principale->BrowseEntry(
      -label => ' 17 ',
      -choices=> \@champs,
        -variable => \$var17,
    )->place( -x => 340, -y => 295);
    $choix18 = $fenetre_principale->BrowseEntry(
      -label => ' 18 ',
      -choices=> \@champs,
        -variable => \$var18,
    )->place( -x => 510, -y => 295);
    $choix19 = $fenetre_principale->BrowseEntry(
      -label => ' 19 ',
      -choices=> \@champs,
        -variable => \$var19,
    )->place( -x => 680, -y => 295);
    $choix20 = $fenetre_principale->BrowseEntry(
      -label => ' 20 ',
      -choices=> \@champs,
        -variable => \$var20,
    )->place( -x => 850, -y => 295);
    ########################################### FIN CHOICES
     
     
    # bouton action 'GENERER'
    my $BoutonGO = $fenetre_principale->Button(
      -text    => "Générer le fichier",
      -command => [\&excel],
    )->place( -x => 1020, -y => 295);
     
    # bouton action 'QUITTER'
    $fenetre_principale->Button(
      -text    => 'Quitter',
      -command => sub { $fenetre_principale->destroy();},
    )->place( -x => 900, -y => 100, );
     
    MainLoop;
     
     
    #############################################################
    ################################################# PARTIE sub
    #############################################################
    sub Colonnes {
      my @select = $lst_f->curselection();
      $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);
          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
          } # if
      } # while
      close IN;
    } # 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 excel {
    print $var1."\n";
    print $var2."\n";
    print $var3."\n";
    print "...\n";
    }

    Il est pas terminé... je bosse encore sur quelques trucs...

    Il surement pas bien écrit...ET... suis preneur de commentaires et améliorations.

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

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

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