IUP - Timer

头像
523066680
Administrator
Administrator
帖子: 465
注册时间: 2016年07月19日 12:14
拥有现金: 锁定
储蓄: 锁定
Has thanked: 51 times
Been thanked: 91 times
联系:

IUP - Timer

帖子 #1 523066680 » 2019年08月13日 23:42

use utf8;
use IUP ':all';
use Date::Format;
use Time::HiRes qw/gettimeofday/;
STDOUT->autoflush(1);

my @label;
my @timer;

for my $id ( 0 .. 2 )
{
$label[$id] = IUP::Label->new(
TITLE => "",
FONT => "Microsoft YaHei",
FONTSIZE=>"18",
EXPAND => "HORIZONTAL",
);

$timer[$id] = IUP::Timer->new(
TIME => 100,# + $id*100,
RUN => "YES",
ACTION_CB => sub {
my $msec = sprintf "%03d", int((gettimeofday)[1]/1000);
$label[$id]->TITLE( time2str("%c ", time()) .$msec );
}
);
}

my $bt_change = IUP::Button->new(
TITLE => "Change",
BUTTON_CB => sub {
# 要使修改的时间间隔生效,必须先暂停 timer
$timer[1]->RUN("NO");
$timer[1]->TIME("500");
$timer[1]->RUN("YES");
}
);

my $dlg = IUP::Dialog->new(
child => IUP::Vbox->new( child => [@label, $bt_change] ),
TITLE => "IupTimer",
SIZE => "300x100",
);

$dlg->Show();

IUP->MainLoop;

回到 “模块”

在线用户

用户浏览此论坛: 没有注册用户 和 1 访客