Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to learn WxPerl and have what I hope is an easy question. With the following code below I'm trying to launch this app and once it starts I then want it to start updating the progress bar based on my sub routine. It must happen automatically. I know I can call my sub via an event through a button etc, but how can I do this automatically after it starts?
Any idea what I'm doing wrong?use Wx qw(:everything); ####################################### # # package MyApp; # # ####################################### use strict; use vars qw(@ISA); @ISA = qw(Wx::App); sub OnInit { my($this) = @_; my($frame) = MyFrame->new( undef, -1, "Checking Updates", [-1,-1], + [330, 220], "wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxS +YSTEM_MENU|wxRESIZE_BORDER|wxFRAME_TOOL_WINDOW|wxCLIP_CHILDREN" ); $frame->CenterOnScreen; $frame->Show(1); $this->SetTopWindow($frame); return 1; } ####################################### # # package MyFrame; # # ####################################### use strict; use Wx qw[:everything]; use base qw(Wx::Frame); Wx::InitAllImageHandlers(); sub new { my( $class ) = shift; my( $this ) = $class->SUPER::new( @_); Wx::StaticBitmap->new($this, -1, Wx::Bitmap->new("C:\\Path to my b +g image.png", wxBITMAP_TYPE_ANY), wxDefaultPosition, wxDefaultSize, ) +; $this->{gauge} = Wx::Gauge->new($this, -1, 100, [10, 150], [200, +20], wxGA_HORIZONTAL|wxGA_SMOOTH); $this->{gauge}->SetForegroundColour(Wx::Colour->new(216, 216, 191) +); check_for_updates(); return $this; } sub check_for_updates { my( $this ) = @_; # Testing <---Problem is here for (1..100) { $this->{gauge}->SetValue( $_ ); sleep 1; } } package main; my($app) = MyApp->new(); $app->MainLoop();
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running a routine in WxPerl?
by pc88mxer (Vicar) on Jun 06, 2008 at 19:22 UTC | |
by Anonymous Monk on Jun 06, 2008 at 20:08 UTC | |
|
Re: Running a routine in WxPerl?
by zentara (Cardinal) on Jun 06, 2008 at 19:31 UTC |