in reply to Re^6: Problem with Tk::Repeat
in thread Problem with Tk::Repeat

Thank you for all the help I really appreciate the gesture of doing a small program :o) and it really make more sense that the book This is how I want it
#!/usr/bin/perl -W use strict; use warnings; use Tk; use Tk::BrowseEntry; use Cwd; use List::Util qw(shuffle); my $mw = MainWindow->new( -relief => 'raised', -bd => 2, ); $mw->title("Asociacion de Agentes Aduanales de Matamoros --- Validacio +n Automatica"); $mw->geometry("1024x764"); my $topframe = $mw->Frame()->pack(-fill=>'x' ); my $mainframe = $mw->Frame()->pack(-expand=>1, -fill=>'both' ); my $exit_b = $topframe->Button(-text=>'Exit', -command=> sub{ exit } )->pack(-side => 'right', -padx=>20 +); my $text1 = $topframe->Label(-text => "Archivos Por enviar")->pack(-si +de => 'left', -expand => 1); my $text2 = $topframe->Label(-text => "Archivos Por Enviados")->pack(- +side => 'left', -expand => 1); my $text3 = $topframe->Label(-text => "Archivos de Respuesta")->pack(- +side => 'left', -expand => 1); my $box1 = Build_Listbox_One($mw); my $box2 = Build_Listbox_Two($mw); my $box3 = Build_Listbox_Three($mw); my ($enviar, $enviados, $respuestas) = Start_Directory_Monitors( $mw, +$box1, $box2, $box3 ); Tk::MainLoop(); sub Build_Listbox_One { my $box1 = $mainframe->Scrolled('Listbox', -scrollbars => 'ose') ->pack( -side => 'left', -expand=>1, -fill=>'both' ); return $box1; } sub Build_Listbox_Two { my $box2 = $mainframe->Scrolled('Listbox', -scrollbars => 'ose') ->pack( -side => 'left', -expand=>1, -fill=>'both' ); return $box2; } sub Build_Listbox_Three { my $box3 = $mainframe->Scrolled('Listbox', -scrollbars => 'ose') ->pack( -side => 'left', -expand=>1, -fill=>'both' ); return $box3; } sub Start_Directory_Monitors { my $mw = shift; my $enviar_display = shift; my $enviados_display = shift; my $respuesta_display = shift; my $enviar = $mw->repeat(5000, [ \&list_dir_enviar, $enviar_di +splay ] ); my $env = $mw->repeat(5000, [ \&list_dir_enviados, $enviados_d +isplay ] ); my $res = $mw->repeat(5000, [ \&list_dir_respuesta, $respuesta_ +display ] ); return $enviar, $env, $res; } # monitor enviados sub list_dir_enviar { my $box = shift; $box->delete(0,'end'); # empty listbox my @items = glob "c:/AAAvalida/valida/enviar/*.*"; foreach (@items) { $box->insert('end', $_); } } sub list_dir_enviados { my $box1 = shift; $box1->delete(0,'end'); # empty listbox my @items = glob "c:/AAAvalida/valida/enviados/*.*"; foreach (@items) { $box1->insert('end', $_); } } sub list_dir_respuesta { my $box2 = shift; $box2->delete(0,'end'); # empty listbox my @items = glob "c:/AAAvalida/valida/respuestas/*.*"; foreach (@items) { $box2->insert('end', $_); } }
Thank you