Reputation: 790
Im trying to play GIF image, which i taken from preloaders site, in my frame:
class TestFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, -1, title, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
self.animation = wx.animate.AnimationCtrl(self, pos=(40,40), size=(24, 24), name="AnimationCtrl")
self.animation.LoadFile("./gui/icons/preloader.gif", wx.animate.ANIMATION_TYPE_GIF)
self.animation.Play()
size = (310, 150)
self.SetSize(size)
self.icon = wx.Icon('./gui/icons/app.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(self.icon)
self.Show()
In result ill will see only all gif (its looks like just imported image at frame). What i doing wrong?
Upvotes: 0
Views: 1414
Reputation: 2295
I tested your code and it worked fine on my computer. I have python 2.7 and wxPython 3.0. If you still haven't solved your problem try using this code:
import wx.animate
class TestFrame2( wx.Frame ):
def __init__( self, parent ):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Testing!", pos = wx.DefaultPosition, size = ( 300,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.RESIZE_BORDER )
self.m_animCtrl1 = wx.animate.AnimationCtrl( self, wx.ID_ANY, wx.animate.NullAnimation, ( 40,40 ), ( -1,-1 ), wx.animate.AC_DEFAULT_STYLE )
self.m_animCtrl1.LoadFile( u"img.GIF" )
self.m_animCtrl1.Play()
self.Layout()
self.Show()
self.Centre( wx.BOTH )
if __name__ == "__main__":
App = wx.App()
TestFrame2(None)
App.MainLoop()
Upvotes: 1
Reputation: 1921
I'm actually using Py3 and wxPython Phoenix, but this code got it working for me.
import wx
from wx.adv import Animation, AnimationCtrl
class TestFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, -1, title)
self.animation = AnimationCtrl(self, pos=(40,40), size=(24, 24), name="AnimationCtrl")
self.animation.LoadFile("animated.gif")
self.animation.Play()
size = (400, 400)
self.SetSize(size)
self.Show()
app = wx.App()
frame = TestFrame(None, -1, "Test gif")
app.MainLoop()
For wxPython I think you need to use a GIFAnimationCtrl instead of AnimationCtrl. I don't have an environment to test it though. Here is the relevant documentation. It's unfortunately pretty sparse.
Even better Blog post with an example. This should give you something to build off of. http://www.daniweb.com/software-development/python/code/216673/wxpython-animated-gif
Upvotes: 2