Hello i'm a french newby in Perl.

I try to create a script which filter a selected file.

goal :

in a 'tk___getOpenFile' I choose my file.

in two 'new_ttk__entry' i want to write

1 / the number of the column of the filter

2 / the filter itself.

i create a new file with the rows containing the filter(1) in the column(2).

i wrote this code :

#!/usr/bin/perl -w use warnings; use strict; use Data::Dumper; use Tkx; my ($lacolonne, @lefiltre); my $types = [ ['CSV Files', ['.csv']], ['Text Files', ['.txt', '.text']], ['All Files', '*'],]; my $fichier = Tkx::tk___getOpenFile( -title => "Sélection du fichie +r à filtrer", -filetypes => $types); unless (-f $fichier) { print "Fichier '$fichier' non trouvé.\n"; exit 2; } unless (@lefiltre) { my $parametre; saisir_2valeurs(\$lacolonne, \$parametre); @lefiltre = qw/$parametre/; } exit 3 unless ($#lefiltre); open IN, $fichier or die "Problème à l'ouverture de $fichier E/S: $!\n +"; while ( <IN> ) { my @enreg = split( /;/, $_ ); for my $filtrage (@lefiltre) { if ($enreg[$lacolonne] =~ /$filtrage/) { open OUT, ">> filtrer_fichier_$filtrage.txt" or die "filtr +er_fichier_$filtrage.txt E/S: $!\n"; print OUT $_ ; close OUT; } } } close IN; =head1 NAME filtre_fichierCSV.pl =head1 SYNOPSIS Interactive mode: perl filtre_fichierCSV.pl <numéro> <filtre> =head1 DESCRIPTION il s'agit de filtrer un fichier sur la colonne <numéro> avec le filtre + <filtre>. le fichier sur lequel appliquer ce filtre est choisi par une fenêtre d +e sélection (Tkx). le fichier généré s'appelle 'filtrer_fichier.txt' =cut sub saisir_2valeurs { use Tkx; my ($saisie1, $saisie2) = @_; my $mw = Tkx::widget->new("."); $mw->g_wm_title("Saisir le type"); my $frm = $mw->new_ttk__frame(-padding => "2 3 12 12"); $frm->g_grid(-column => 0, -row => 0, -sticky => "nwes"); my $e_colonn = $frm->new_ttk__entry(-width => 9, -textvariable => +$saisie1); $e_colonn->g_grid(-column => 2, -row => 1, -sticky => "we"); my $e_filtre = $frm->new_ttk__entry(-width => 9, -textvariable => +$saisie2); $e_filtre->g_grid(-column => 2, -row => 2, -sticky => "we"); my $cb = $frm->new_ttk__button(-text => "Valider la saisie", -comm +and => sub { $mw->g_destroy; }); $cb->g_grid(-column => 3, -row => 3, -sticky => "w"); $frm->new_ttk__label(-text => "Le numéro de colonne du filtre :")- +>g_grid(-column => 1, -row => 1, -sticky => "e"); $frm->new_ttk__label(-text => "Le filtre à extraire (qw) :")- +>g_grid(-column => 1, -row => 2, -sticky => "e"); foreach (Tkx::SplitList($frm->g_winfo_children)) { Tkx::grid_configure($_, -padx => 5, -pady => 5); } $e_colonn->g_focus; $mw->g_bind("<Return>", sub { $mw->g_destroy; }); $mw->g_tkwait_window; Tkx::MainLoop(); print "dans la fenetre $saisie1,$$saisie1; $saisie2,$$saisie2.\n"; }

but i can't write in any of the 2 'new_ttk__entry' !

Why ?

they seem to be disabled or in readonly mode, i don't know ...

can anyone explain me what is the problem ? and of course how to solve it ;-)

best regards

PS

with one 'tk___chooseDirectory' and one 'new_ttk__entry', i cant write in the 'new_ttk__entry'.


In reply to using Tkx new_ttk__entry AND tk___getOpenFile by x-lours

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.