2012-11-08 17 views

回答

1

我不知道PyEmbeddedImage和img2py.py,但這裏是我發現將動畫嵌入python源代碼的一種方式。

gif_img_base64 = (
    "R0lGODlhEAAQAPQAAP///wAAAPDw8IqKiuDg4EZGRnp6egAAAFhYWCQkJKysrL" 
    "6+vhQUFJycnAQEBDY2NmhoaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" 
    ... 
    "PAqFgYy02xkSaLEMV34tELyRYNEsCQyHlvWkGCzsPgMCEAY7Cg04Uk48LAsDhR" 
    "A8MVQPEF0GAgqYYwSRlycNcWskCkApIyEAOwAAAAAAAAAAAA==" 
) 

a = wx.animate.GIFAnimationCtrl(self, -1, '') # The control 

a2 = wx.animate.Animation() # The data 
data = base64.b64decode(gif_img_base64) 
a2.Load(cStringIO.StringIO(data)) 
a.SetAnimation(a2) # Bind the data and the control 

a.GetPlayer().UseBackgroundColour(True) 
a.Play() 

變量gif_img_base64是帶動畫的GIF文件的base64編碼內容。幫助程序創建代碼:

import sys, base64 
data = sys.stdin.read() 
s = base64.b64encode(data) 
print 'gif_img_base64 = (' 
while s: 
    print ' "' + s[:62] + '"' 
    s = s[62:] 
print ' )' 
相關問題