background process

Sounds ok to me, but I'm no guru. Also, there are a limited amount of
wxTimers that you may construct. (i've never hit the limit myself).

jw

···

-----Original Message-----
From: travis [mailto:travis.smith@tycoelectronics.com]
Sent: Wednesday, July 09, 2003 3:16 PM
To: wxpython
Subject: RE: [wxPython-users] background process

Thanks, that's exactly what I was looking for. It'll help out a ton.
Then I suppose I would just set up a separate timer event for each
separate thing that needed to happen at different time intervals?

On Wed, 2003-07-09 at 13:36, Wyant, Jaime wrote:

Try a wxTimer. Check out the code below.

from wxPython.wx import *

class MyFrame( wxFrame ):
    def __init__( self ):
        wxFrame.__init__( self, None, -1, "Test" )
        self.SetSize( wxSize( 240, 240 ) )

        # Create a timer. First create the timer's id
        timer_id = wxNewId()

        # Now construct the timer
        self.timer = wxTimer(self, timer_id )

        # Create an event handler for the timer
        EVT_TIMER(self, timer_id, self.on_time )

        # Start the timer
        self.timer.Start( 2000 )

    def on_time( self, e ):
        print " 2 seconds have elapsed since the timer started "

class MyApp( wxApp ):
    def OnInit( self ):
        frame = MyFrame()
        frame.Show( true )
        return true

def main():
    app = MyApp(0)
    app.MainLoop()

if __name__ == "__main__":
    main()

HTH,
jw

>>-----Original Message-----
>>From: travis [mailto:travis.smith@tycoelectronics.com]
>>Sent: Wednesday, July 09, 2003 2:06 PM
>>To: wxpython
>>Subject: [wxPython-users] background process
>>
>>
>>Hi,
>>
>>I'm working on a queuing program and have been able to make
>>the gui and
>>have it work as I'd expected, but I'm running into

trouble with having

>>the script keep doing something in between gui events.

What I have is

>>two queues in listboxes with which I can manipulate items up
>>and down as
>>well as move them from queue to queue. What I'd like to

do is every

>>couple of seconds, regardless of user input, delete the

top item from

>>each queue until everything is done.
>>
>>The structure of my program is pretty simple, mostly I just
>>need to know
>>where to put the instructions where they'll get executed

repeatedly,

>>regardless of other things. I've attached the script so
>>it'll be easier
>>to see what I'm doing.
>>
>>
>>
>>Thanks in advance,
>>--
>>
>>Travis Smith
>>Unix Systems Manager
>>Tyco Electronics PCG
>>Logan, Utah
>>435-753-4700 x3030
>>

---------------------------------------------------------------------

To unsubscribe, e-mail:

wxPython-users-unsubscribe@lists.wxwindows.org

For additional commands, e-mail:

wxPython-users-help@lists.wxwindows.org
--

Travis Smith
Unix Systems Manager
Tyco Electronics PCG
Logan, Utah
435-753-4700 x3030

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwindows.org

Wyant, Jaime wrote:

Sounds ok to me, but I'm no guru. Also, there are a limited amount of
wxTimers that you may construct. (i've never hit the limit myself).

From: travis [mailto:travis.smith@tycoelectronics.com]

Thanks, that's exactly what I was looking for. It'll help out a ton. Then I suppose I would just set up a separate timer event for each
separate thing that needed to happen at different time intervals?
     
If you need more than a handful of timers, one alternative would be to set up a single timer that fires off fairly often. Each task can keep track of the last time it was run, and on every timer event, it compares that with the current time. If the difference is great enough, then it runs (updating its last-run time). The timer event, instead of meaning "Fire off this task now", becomes "Check all tasks, and fire off any that are stale". This would probably be a bit more overhead if there's only two or three tasks, but may make a lot more sense if the number of tasks is a significant fraction of the number of available timers.

Jeff Shannon
Technician/Programmer
Credit International