Prevent controls animating that aren't visible

I have a custom drawn control, which is a descendant of wx.Panel that animates. There’s a timer which pulses at set intervals to prompt controls like this to do some painting.

I’ve noticed that this happens when the whole app is hidden / minimized or just if the panel that the control is placed on is hidden.

What would be the best approach to only animate the control when it’s visible, or at least not hidden?

Also, if there’s a more elegant way of achieving this I’d also be interested :slight_smile:

Paul

Periodically check self.IsShownOnScreen(), and start/stop your timer accordingly.

···

On 11/14/12 6:45 AM, Paul Wiseman wrote:

I have a custom drawn control, which is a descendant of wx.Panel that
animates. There's a timer which pulses at set intervals to prompt
controls like this to do some painting.

I've noticed that this happens when the whole app is hidden
/ minimized or just if the panel that the control is placed on is hidden.

What would be the best approach to only animate the control when
it's visible, or at least not hidden?

--
Robin Dunn
Software Craftsman

Ah- I didn’t know about that method! I’ll give that a go now :slight_smile:

Thanks!

···

On 16 November 2012 05:50, Robin Dunn robin@alldunn.com wrote:

On 11/14/12 6:45 AM, Paul Wiseman wrote:

I have a custom drawn control, which is a descendant of wx.Panel that

animates. There’s a timer which pulses at set intervals to prompt

controls like this to do some painting.

I’ve noticed that this happens when the whole app is hidden

/ minimized or just if the panel that the control is placed on is hidden.

What would be the best approach to only animate the control when

it’s visible, or at least not hidden?

Periodically check self.IsShownOnScreen(), and start/stop your timer accordingly.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en