Bonjour,
Dans Introduction à Perl/Tk de Nancy Walsh p191 il est précisé comment obtenir des informations concernant une ligne dans un widget texte :
($x, $y, $l, $h, $base) = $texte->dlineinfo("indice");
Dans une fonction, le programme complet est ICI, je tente d'obtenir les informations concernant la dernière ligne écrite :
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
| sub Regex {
if ( !$Regex ) {
$LabRegex = "Regex vide !";
$LabMessage = "Regex vide !";
print "\a\a";
return;
}
my $TexteInput = $widget_input->get( '1.0', 'end' );
my $Pattern = $Regex;
$Pattern =~ s/ /\\ /go;
$LabRegex = $Pattern;
my $i = 0;
my @array = ($TexteInput =~ m/(\b.{0,40}$Pattern.{0,40}\b)/gx);
my $Nb = @array;
if ($Nb == 1){
my @NewArray = split /$Pattern/, $TexteInput ;
$widget_output->insert( 'end', $NewArray[0]." " );
$widget_output->see( 'end' );
my ($x, $y, $l, $h, $base) = $widget_output->dlineinfo( 'end' );
$widget_output->insert( 'end', $Regex." ", "g22");
$widget_output->insert( 'end', $NewArray[1] );
$LabRegex = "$x $y $l $h $base"; # juste pour voir ce qu'il y a dans ces variables...
} else {
foreach my $Ligne ( @array ) {
$widget_output->insert( 'end', ++$i .": ".$Ligne."\n" );
}
}
} |
Mon but serait de faire si possible un see sur le widget input avec les informations de positionnement obtenues dans le widget output.
Les widgets input et output contiennent le même texte hors mis que dans le output j'ai le pattern sous la forme regex.
En me positionnant approximativement au même endroit dans le widget input je devrais voir la chaîne réelle.
Cependant, bien que la position dans le widget output soit visible, je viens de faire :
$widget_output->see( 'end' );
J'ai tenté d'ajouter sans succès :
La ligne suivante :
my ($x, $y, $l, $h, base) = $widget_output->dlineinfo( 'end' );
me renvoie des variables non initialisées.
Avez-vous une idée ?
D'avance MERCI !
Partager