I'm looking at the wxTimer Doc. and I am trying to create an event timer.have created an event timer.

this is the code I have so far, but it's not working. I can't seem to figure out what I'm doing wrong. It works, but seems to eat resources, even though it's not doing much...

#!/usr/bin/perl use strict; use warnings; use Wx; package MyFrame; use base 'Wx::Frame'; use Wx::Event qw(EVT_BUTTON); sub new { my $ref = shift; my $self = $ref->SUPER::new( undef, #Parent Window -1, #Window ID (-1 means any) 'wxPerl', #Window Title [-1, -11], #Default Position [250, 250], #size ); #create panel my $panel = Wx::Panel->new ( $self, #parent window -1, #id ); #create button my $button = Wx::Button->new( $panel, # Parent Panel -1, # id 'Click Me!', # label [30, 20], # position [-1, -1], # default size ); my $timer = Wx::Timer->new( $self, # Parent Frame -1, # Timer ID ); $timer->Start(1); EVT_TIMER $self, $timer, \&do_stuff; EVT_BUTTON $self, $button, \&on_click_button; return $self; } sub on_click_button { my ($self, $event) = @_; $self->SetTitle( 'Clicked'); } sub do_stuff { #get current focus Id; #determine if the ID has changed #etc } package MyTimer; use base 'Wx::Timer'; sub new { my $self = shift; my $timer = Wx::Timer->wxTimer(); return $timer; } 1; package MyApp; use base 'Wx::App'; sub OnInit { my $timer = MyTimer->new; $timer->Start(1); my $frame = MyFrame->new; $frame->Show(1); } package main; my $app = MyApp->new; $app->MainLoop;

I'm really not sure how to construct the MyTimer object.

EDIT: To fix timer

Timer problem has been resolved. Any suggestions on the new solution to the timer presented?

I started this thread to work on the timer part of the application. for the full application please refer to this thread.


In reply to Wx Event timer by PyrexKidd

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.