进度条升级 Perl Win32::GUI
Posted
技术标签:
【中文标题】进度条升级 Perl Win32::GUI【英文标题】:Progress Bar step up Perl Win32::GUI 【发布时间】:2012-03-23 06:18:36 【问题描述】:我正在使用 perl Win32::GUI 开发一个桌面应用程序。我正在使用进度条进行状态识别。 我已将进度条的最大级别设置为 100。因为我会根据长度提高值。 我已经编写了下面的示例代码。我通过将 100 除以输入长度来计算步进值。在那里,如果输入长度是奇数,则步长值将是浮点数。因此,进度条没有完全完成其***别。 例如,如果长度为 11,则步进值为 9.09。 进度条仅将其视为 9。因此,进度级别仅完成 99 个分段。不是 100。请分享您的建议。
use strict;
use Win32;
use Win32::GUI;
my $DOS = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($DOS);
my $Upload_win=Win32::GUI::Window->new(
-name => 'UploadWindow',
-text => 'SVN-CHIP-Upload-Tool-V2-HurixSystems',
-left => 375,
-top => 400,
-width =>520,#370,
-height =>520,
#-menu =>$Menu,
-background => [190,190,190],
-dialogui => 1,
-maximizebox => 0,
);
my $ProcessButton=$Upload_win->AddButton(
-text => 'Upload',
-name => 'uploadbut',
-size => [90,25],
-pos => [200,360],
-background => [190,190,190],
-foreground => [],
-tabstop => 1,
);
my $Progress_bars=$Upload_win->AddProgressBar(
-pos=>[20,400],
-background=>[0,255,85],
-smooth => 1,
-size=>[470,20],
);
$Upload_win->Show();
Win32::GUI::Dialog();
Win32::GUI::Hide($DOS);
sub uploadbut_Click
$Progress_bars->SetRange(0,100);
my $x=11;
my $y=100/$x;
for(1..$x)
Win32::GUI::DoEvents() >= 0;
$Progress_bars->SetStep($y);
$Progress_bars->StepIt();
sleep 1;
【问题讨论】:
【参考方案1】:您可以将进度条的长度设置为您的步数和步长的乘积:
#!perl
use strict;
use Win32;
use Win32::GUI();
my $DOS = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($DOS);
my $Upload_win=Win32::GUI::Window->new(
-name => 'UploadWindow',
-text => 'SVN-CHIP-Upload-Tool-V2-HurixSystems',
-left => 375,
-top => 400,
-width => 520,
-height =>520,
-background => [190,190,190],
-dialogui => 1,
-maximizebox => 0,
);
my $ProcessButton=$Upload_win->AddButton(
-text => 'Upload',
-name => 'uploadbut',
-size => [90,25],
-pos => [200,360],
-background => [190,190,190],
-foreground => [],
-tabstop => 1,
);
my $Progress_bars=$Upload_win->AddProgressBar(
-pos=>[20,400],
-background=>[0,255,85],
-smooth => 1,
-size=>[470,20],
);
$Upload_win->Show();
Win32::GUI::Dialog();
Win32::GUI::Hide($DOS);
sub uploadbut_Click
my $intended_max = 100;
my $x = 11;
my $y = int($intended_max/$x);
$Progress_bars->SetRange(0,$x*$y);
for(1 .. $x)
Win32::GUI::DoEvents();
$Progress_bars->SetStep($y);
$Progress_bars->StepIt();
Win32::Sleep(1000);
【讨论】:
以上是关于进度条升级 Perl Win32::GUI的主要内容,如果未能解决你的问题,请参考以下文章