How can I combine dynamically timer events ?

hello,

I dynamically create ogl.Shapes,
and some of these objects needs a regular refresh.
So with the help of "Nitro", I realized it for 1 object,
like this:

class T6963_device (ogl.BitmapShape):
  def __init__(self, Container):
    ogl.BitmapShape.__init__ (self)

    # Create a timer, and fetch the event of the container
    self.t1 = wx.Timer (Container)
    Container.Bind(wx.EVT_TIMER, self.OnTimer)
    self.t1.Start ( 100 )

  def OnTimer (self, event):
    LCD.Invalidate()
    print 'beer'

This works great for the first object created,
but if I create another ogl.shape object,
that also needs a timer for some regular refresh,
the event binding goes to the second object,
ans the actions of my first object will nor be performed anymore.

So how do I join multiple actions from different objects in the same container ?

thanks,
Stef Mientki

Stef Mientki wrote:

hello,

I dynamically create ogl.Shapes,
and some of these objects needs a regular refresh.
So with the help of "Nitro", I realized it for 1 object,
like this:

class T6963_device (ogl.BitmapShape):
def __init__(self, Container):
   ogl.BitmapShape.__init__ (self)

   # Create a timer, and fetch the event of the container
   self.t1 = wx.Timer (Container)
   Container.Bind(wx.EVT_TIMER, self.OnTimer)
   self.t1.Start ( 100 )

def OnTimer (self, event):
   LCD.Invalidate()
   print 'beer'

     event.Skip()

will do it.

Christian

Christian K wrote:

Stef Mientki wrote:
  

hello,

I dynamically create ogl.Shapes,
and some of these objects needs a regular refresh.
So with the help of "Nitro", I realized it for 1 object,
like this:

class T6963_device (ogl.BitmapShape):
def __init__(self, Container):
   ogl.BitmapShape.__init__ (self)

   # Create a timer, and fetch the event of the container
   self.t1 = wx.Timer (Container)
   Container.Bind(wx.EVT_TIMER, self.OnTimer)
   self.t1.Start ( 100 )

def OnTimer (self, event):
   LCD.Invalidate()
   print 'beer'
    
     event.Skip()

will do it.
  

Thanks Cristian.

btw, what a strange name "Skip",
what is there to be skipped ?
In Delphi this is called "inherited", which I can understand better.

cheers,
Stef Mientki

···

Christian

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

Stef Mientki wrote:

Christian K wrote:

Stef Mientki wrote:

hello,

I dynamically create ogl.Shapes,
and some of these objects needs a regular refresh.
So with the help of "Nitro", I realized it for 1 object,
like this:

class T6963_device (ogl.BitmapShape):
def __init__(self, Container):
   ogl.BitmapShape.__init__ (self)

   # Create a timer, and fetch the event of the container
   self.t1 = wx.Timer (Container)
   Container.Bind(wx.EVT_TIMER, self.OnTimer)
   self.t1.Start ( 100 )

def OnTimer (self, event):
   LCD.Invalidate()
   print 'beer'
    
     event.Skip()

will do it.
  

Thanks Cristian.

btw, what a strange name "Skip",
what is there to be skipped ?
In Delphi this is called "inherited", which I can understand better.

Skip means that the event should not end its journey at this particular event
handler but rather skip it so that other event handlers will be able to receive
it, too. I don't find the name that bad.

Christian

Thanks Cristian.

btw, what a strange name "Skip",
what is there to be skipped ?
In Delphi this is called "inherited", which I can understand better.
    
Skip means that the event should not end its journey at this particular event
handler but rather skip it so that other event handlers will be able to receive
it, too. I don't find the name that bad.
  

ok, what's in a name.

But a few more essential questions:
- does it matter where the "Skip()" is placed (at the beginning or the end) of my own event handling ?
- is it allowed to place a "Skip()" in all the event handlers that should "chain" actions ?
- I should have started with this question :wink: any good link to "Skip()" function ?

thanks,
Stef Mientki

Stef Mientki wrote:

Thanks Cristian.

btw, what a strange name "Skip",
what is there to be skipped ?
In Delphi this is called "inherited", which I can understand better.
    
Skip means that the event should not end its journey at this
particular event
handler but rather skip it so that other event handlers will be able
to receive
it, too. I don't find the name that bad.
  

ok, what's in a name.

But a few more essential questions:
- does it matter where the "Skip()" is placed (at the beginning or the
end) of my own event handling ?

anywhere is fine. The next handler will not be called before your app is back in
the main loop anyway.

- is it allowed to place a "Skip()" in all the event handlers that
should "chain" actions ?

I think so, yes.

Btw. some events can be vetoed calling event.Veto() in the event handler thus
preventing them from happening.

Christian

thanks for the answers Cristian.

cheers
Stef Mientki

Christian K wrote:

···

Stef Mientki wrote:
  

Thanks Cristian.

btw, what a strange name "Skip",
what is there to be skipped ?
In Delphi this is called "inherited", which I can understand better.
    

Skip means that the event should not end its journey at this
particular event
handler but rather skip it so that other event handlers will be able
to receive
it, too. I don't find the name that bad.
  

ok, what's in a name.

But a few more essential questions:
- does it matter where the "Skip()" is placed (at the beginning or the
end) of my own event handling ?
    
anywhere is fine. The next handler will not be called before your app is back in
the main loop anyway.

- is it allowed to place a "Skip()" in all the event handlers that
should "chain" actions ?
    
I think so, yes.

Btw. some events can be vetoed calling event.Veto() in the event handler thus
preventing them from happening.

Christian

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

In general, you should always call Skip() unless you know exactly what
behavior you're preventing by not calling it.

···

On 6/10/07, Christian K <ckkart@hoc.net> wrote:

Stef Mientki wrote:
>
> - is it allowed to place a "Skip()" in all the event handlers that
> should "chain" actions ?

I think so, yes.

Btw. some events can be vetoed calling event.Veto() in the event handler thus
preventing them from happening.

Stef Mientki wrote:

hello,

I dynamically create ogl.Shapes,
and some of these objects needs a regular refresh.
So with the help of "Nitro", I realized it for 1 object,
like this:

class T6963_device (ogl.BitmapShape):
def __init__(self, Container):
   ogl.BitmapShape.__init__ (self)

   # Create a timer, and fetch the event of the container
   self.t1 = wx.Timer (Container)
   Container.Bind(wx.EVT_TIMER, self.OnTimer)
   self.t1.Start ( 100 )

def OnTimer (self, event):
   LCD.Invalidate()
   print 'beer'

This works great for the first object created,
but if I create another ogl.shape object,
that also needs a timer for some regular refresh,
the event binding goes to the second object,
ans the actions of my first object will nor be performed anymore.

So how do I join multiple actions from different objects in the same container ?

You've already gotten some answers relating to using Skip to allow a single even to propagate to multiple handlers, but it sounds to me like you are actually wanting something else. You want to be able to have multiple timers and each one will call a different handler when it expires, right? To do that you just need to use the timer object as the source parameter to the Bind method, like this:

     Container.Bind(wx.EVT_TIMER, self.OnTimer, self.t1)

This way self.OnTimer will only be called when self.t1 notifies, not when *all* the timers sending events to Container notify.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Chris,

> Stef Mientki wrote:
> >
> > - is it allowed to place a "Skip()" in all the event handlers that
> > should "chain" actions ?
>
> I think so, yes.
>
> Btw. some events can be vetoed calling event.Veto() in the event handler thus
> preventing them from happening.
>

In general, you should always call Skip() unless you know exactly what
behavior you're preventing by not calling it.

This is somewhat contradicting what I found when I wrote GUI2Exe: Mac
users reported that calling Skip on menu events (whatever a Skip
instruction may do on menu handlers...) was not a Good Thing.
Actually, calling Skip on menu events caused the same menu handler to
be called forever and ever, in an evil "circulus vitiosus" without
end. From one side, I was warned that calling Skip was not a good
idea, while my usual programming practice was (and still is) to call
Skip on all events unless I know what I am blocking.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

···

On 6/11/07, Chris Mellon wrote:

On 6/10/07, Christian K <ckkart@hoc.net> wrote:

Andrea Gavana wrote:

In general, you should always call Skip() unless you know exactly what
behavior you're preventing by not calling it.

This is somewhat contradicting what I found when I wrote GUI2Exe: Mac
users reported that calling Skip on menu events (whatever a Skip
instruction may do on menu handlers...) was not a Good Thing.

my usual programming practice was (and still is) to call
Skip on all events unless I know what I am blocking.

As it happens, I don't think I've EVER called Skip(), certainly rarely.

I guess it depends on what you're doing.

-CHB

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

So how do I join multiple actions from different objects in the same container ?

You've already gotten some answers relating to using Skip to allow a single even to propagate to multiple handlers, but it sounds to me like you are actually wanting something else. You want to be able to have multiple timers and each one will call a different handler when it expires, right?

Robin, You hit the nail right on its head !

To do that you just need to use the timer object as the source parameter to the Bind method, like this:

    Container.Bind(wx.EVT_TIMER, self.OnTimer, self.t1)

Works great, and I don't need the Skip anymore !

This way self.OnTimer will only be called when self.t1 notifies, not when *all* the timers sending events to Container notify.

thanks,
Stef Mientki