Hi all,
Below is my code. With this code, 12345 will show at once
after 5 seconds I click the button.
But what I want is to insert() each number per second.
Is that something I can do like $| = 1 in such case ?
At least, could anybody tell this is the behavior of insert () ?
or it's the behavior of -command => sub {} ?
Thank you very much !
==============================
use Tk;
sub SetButton {
$_[0]->{mw} -> Button ( -text=>'click me',
-command => sub { $_[0] ->RollText() }
) -> pack ();
}
sub RollText{
for ( 1..5 ) {
$_[0] ->{mw}{box} -> insert ( 'end', $_ ) ;
sleep 1;
}
}
sub SetText {
$_[0]->{mw}{box} = $class->{mw} -> Text ( -width => 10 , -height => 10 )
-> pack();
}
sub Build {
my $self = {} ;
$self -> {mw} = MainWindow -> new ( -title => 'goodbye world' ) ;
return bless $self ;
}
my $class = Build ();
$class -> SetText ;
$class -> SetButton ;
MainLoop();