我有这段代码:
#!/usr/bin/perl
use strict;
use Tkx;
my $mw = Tkx::widget->new('.');
$mw->g_wm_minsize( 400, 350 );
my $btn_start = $mw->new_ttk__button( -text => "Start", -width => 60, -command => sub { start(); } );
my $txt_processed_domains = $mw->new_tk__text( -width => 40, -height => 10, -state => "disabled", -wrap => "none" );
Tkx::grid( $btn_start, -row => 2, -columnspan => 3, -padx => 10, -pady => 10 );
Tkx::grid( $txt_processed_domains, -row => 3, -columnspan => 3, -padx => 10, -pady => 10 );
Tkx::MainLoop();
sub start {
foreach my $id ( 1.. 10 ) {
$txt_processed_domains->configure(-state => "normal");
$txt_processed_domains->insert_end( "$id => Available\n" );
$txt_processed_domains->configure(-state => "disabled");
sleep 1;
}
Tkx::tk___messageBox( -message => "Completed!" );
}
我需要查看哪些ID已处理,但最后只能获得整个列表。这就像使用文件句柄缓冲,但我不确定。如何在插入文本框后立即查看文本?
答案 0 :(得分:1)
我发现Tkx::update();
做了我想做的事。
答案 1 :(得分:1)
Tkx :: update_idletasks()将是首选呼叫。