wxPython Animated Gif

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
vegaseat vegaseat is offline Offline Nov 22nd, 2005, 11:52 pm |
0
Version 2.6 of wxPython has support for playing animated gif image files. The example sets up a panel on a frame and then uses wx.animate.GIFAnimationCtrl() to do the hard work. Actually pretty simple code.
Quick reply to this message  
Python Syntax
  1. # display an animated GIF image file using wxPython
  2. # tested with Python24 and wxPython26 vegaseat 22nov2005
  3.  
  4. import wx
  5. import wx.animate # ..\wx\animate.py
  6.  
  7. class MyPanel(wx.Panel):
  8. """ class MyPanel creates a panel, inherits wx.Panel """
  9. def __init__(self, parent, id):
  10. # default pos and size creates a panel that fills the frame
  11. wx.Panel.__init__(self, parent, id)
  12. self.SetBackgroundColour("white")
  13. # pick the filename of an animated GIF file you have ...
  14. # give it the full path and file name!
  15. ag_fname = "D:/Python24/Atest/wx/AG_Dog.gif"
  16. ag = wx.animate.GIFAnimationCtrl(self, id, ag_fname, pos=(10, 10))
  17. # clears the background
  18. ag.GetPlayer().UseBackgroundColour(True)
  19. # continuously loop through the frames of the gif file (default)
  20. ag.Play()
  21.  
  22.  
  23. app = wx.PySimpleApp()
  24. # create a window/frame, no parent, -1 is default ID
  25. # give it a size so the image will fit ...
  26. frame = wx.Frame(None, -1, "wx.animate.GIFAnimationCtrl()", size = (500, 400))
  27. # call the derived class, -1 is default ID
  28. MyPanel(frame, -1)
  29. # show the frame
  30. frame.Show(True)
  31. # start the event loop
  32. app.MainLoop()

Message:


Similar Threads
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC