#!/usr/bin/perl use Wx; package MyApp; use strict; use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my($this) = @_; my($frame) = MyFrame->new("Progress bar demo", Wx::Point->new(50, 50), Wx::Size->new(450, 350)); $this->SetTopWindow($frame); $frame->Show(1); 1; } package MyFrame; use strict; use vars qw(@ISA); @ISA=qw(Wx::Frame); use Wx::Event qw(EVT_MENU); use Wx qw(wxBITMAP_TYPE_ICO wxMENU_TEAROFF); sub new { my($class) = shift; my($this) = $class->SUPER::new(undef, -1, $_[0], $_[1], $_[2]); my($mfile) = Wx::Menu->new(undef, wxMENU_TEAROFF); my($ID_TEST, $ID_EXIT) = (1, 2); $mfile->Append($ID_TEST, "&Test Progress Dialog\tCtrl-T", "Display a test dialog"); $mfile->Append($ID_EXIT, "E&xit\tAlt-X", "Quit this program"); my($mbar) = Wx::MenuBar->new(); $mbar->Append($mfile, "&Test"); $this->SetMenuBar($mbar); EVT_MENU($this, $ID_TEST, \&OnTest); EVT_MENU($this, $ID_EXIT, \&OnQuit); $this; } sub OnQuit { my($this, $event) = @_; $this->Close(1); } use Wx qw(wxOK wxICON_INFORMATION wxVERSION_STRING); use Wx qw(:progressdialog); sub OnTest { my($this, $event) = @_; my($max) = 10; my $dialog = Wx::ProgressDialog->new('Progress dialog example', 'An example', $max, $this, wxPD_CAN_ABORT| wxPD_APP_MODAL|wxPD_ELAPSED_TIME| wxPD_ESTIMATED_TIME| wxPD_REMAINING_TIME); my ($usercontinue) = 1; foreach (1 .. $max) { $usercontinue = $dialog->Update($_); print $usercontinue; last if $usercontinue==0; sleep (1); } $dialog->Destroy; } package main; my($app) = MyApp->new(); $app->MainLoop();