Prevent controls animating that aren't visible

13 views
Skip to first unread message

Paul Wiseman

unread,
Nov 14, 2012, 9:45:23 AM11/14/12
to wxpytho...@googlegroups.com
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 :)

Paul


Robin Dunn

unread,
Nov 16, 2012, 12:50:14 AM11/16/12
to wxpytho...@googlegroups.com
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

Paul Wiseman

unread,
Nov 16, 2012, 5:59:43 AM11/16/12
to wxpytho...@googlegroups.com

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

Thanks!
Reply all
Reply to author
Forward
0 new messages