Hello monks,

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?

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();
Any idea what I'm doing wrong?

Thanks


In reply to Running a routine in WxPerl? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.