Ciao a tutti,
premetto che non sono un programmatore ma da qualche tempo eseguo semplici script in perl che elaborano file o interrogano database. In questi giorni mi sto avvicinando a Perl/tk per inserire questi script in finestre windows in modo da poter aggiungere bottoni, listbox ecc... e rendere così l'applicazione più interattiva ma mi scontro con un problema che non riesco a risolvere in nessun modo. Oggi questi script ciclano in continuazione scanditi da alcuni sleep posti nello script e quando li integro in finestre GUI queste mi si bloccano finchè il tempo impostato nello sleep non è trascorso.
Inserisco un esempio per farvi capire meglio e spero che qualcuno sappia aiutarmi....
Grazie a tutti.
use Tk;
$mw = MainWindow->new;
$mw->title('text');
$lb = $mw->Scrolled('Text',-width => 40,-height => 16,-background => yellow,-font => 'Tahoma 10 bold',-scrollbars => 'osow');
$lb->tagConfigure('BLUE',-foreground => 'blue');
$lb->tagConfigure('LTBLUE',-foreground => 'light blue');
$lb->tagConfigure('RED',-foreground => 'red');
$lb->tagConfigure('GREEN',-foreground => 'green');
$lb->tagConfigure('LTRED',-foreground => 'orange');
$lb->tagConfigure('LTGREY',-foreground => 'light grey');
$lb->tagConfigure('YELLOW',-foreground => 'yellow');
$via = $mw->Button(-text => 'Start',-width => 4,-height => 1,-font => 'Tahoma 15 bold',-command => \&message);
$exit = $mw->Button(-text => 'Exit',-width => 4,-height => 1,-font => 'Tahoma 15 bold',-command => [$mw => 'destroy']);
$lb->pack;
$via->pack(-side => 'left',-expand => 1);
$exit->pack(-side => 'left',-expand => 1);
MainLoop;
sub message {
INIZIO:
{
while ($message<5)
{
$message++;
$lb->insert('end', $message."\n", 'RED');
$lb->update;
sleep 5;
}
$message="prova"."\n";
$lb->insert('end', $message,'BLUE');
$lb->update;
sleep 5;
redo INIZIO;
}
}