Can't get wxAnimationCtrl to work

Hi,

I'm using wxAnimationCtrl in my Python program but can't get it to
work.

<object class="wxAnimationCtrl" name="AnimationCtrl">
          <style>wxAC_DEFAULT_STYLE</style>
          <animation></animation>

self.animation = xrc.XRCCTRL( self.loginpanel, "AnimationCtrl" )
self.animation.LoadFile( "loading.gif", wx.ANIMATION_TYPE_GIF )
self.animation.Play()

I get the following error:

self.animation.LoadFile( "loading.gif", wx.ANIMATION_TYPE_GIF )
AttributeError: 'Control' object has no attribute 'LoadFile'

Looking in the docs I find AnimationCtrl is derived from
AnimationCtrlBase which contains the LoadFile() method. Ergo, it
should work.

Anyone used AnimationCtrl with wxPython and XRC?

You need to import wx.animate in your Python code, so wxPython knows about the wx.animate.AnimationCtrl proxy class. Once it has loaded the class (and some type information about it) then wxPython will be able to wrap an instance of the proxy class around the wx.Window pointer returned by XRCCTRL. Otherwise wxPython has to go up the class hierarchy until it finds a class that it does know about, in this case it was wx.Control.

···

On 3/17/10 12:04 AM, BigPilot wrote:

Hi,

I'm using wxAnimationCtrl in my Python program but can't get it to
work.

<object class="wxAnimationCtrl" name="AnimationCtrl">
          <style>wxAC_DEFAULT_STYLE</style>
          <animation></animation>

self.animation = xrc.XRCCTRL( self.loginpanel, "AnimationCtrl" )
self.animation.LoadFile( "loading.gif", wx.ANIMATION_TYPE_GIF )
self.animation.Play()

I get the following error:

self.animation.LoadFile( "loading.gif", wx.ANIMATION_TYPE_GIF )
AttributeError: 'Control' object has no attribute 'LoadFile'

Looking in the docs I find AnimationCtrl is derived from
AnimationCtrlBase which contains the LoadFile() method. Ergo, it
should work.

--
Robin Dunn
Software Craftsman

Thanks Robin, got it working!

···

On Mar 17, 6:24 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 3/17/10 12:04 AM, BigPilot wrote:

> Hi,

> I'm using wxAnimationCtrl in my Python program but can't get it to
> work.

> <object class="wxAnimationCtrl" name="AnimationCtrl">
> <style>wxAC_DEFAULT_STYLE</style>
> <animation></animation>

> self.animation = xrc.XRCCTRL( self.loginpanel, "AnimationCtrl" )
> self.animation.LoadFile( "loading.gif", wx.ANIMATION_TYPE_GIF )
> self.animation.Play()

> I get the following error:

> self.animation.LoadFile( "loading.gif", wx.ANIMATION_TYPE_GIF )
> AttributeError: 'Control' object has no attribute 'LoadFile'

> Looking in the docs I find AnimationCtrl is derived from
> AnimationCtrlBase which contains the LoadFile() method. Ergo, it
> should work.

You need to import wx.animate in your Python code, so wxPython knows
about the wx.animate.AnimationCtrl proxy class. Once it has loaded the
class (and some type information about it) then wxPython will be able to
wrap an instance of the proxy class around the wx.Window pointer
returned by XRCCTRL. Otherwise wxPython has to go up the class
hierarchy until it finds a class that it does know about, in this case
it was wx.Control.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org