裸奔的句子 发布于 2014/09/24 19:46
阅读 1K+
收藏 0
wapython,如何把欢迎界面的图片转换为py程序
1).我的代码:
class PaintApp(wx.App):
def OnInit(self):
bmp = wx.Image(“girl.bmp”).ConvertToBitmap()
wx.SplashScreen(bmp,wx.SPLASH_CENTER_ON_SCREEN | wx.SPLASH_TIMEOUT,2000,None,-1)
wx.Yield()
return True
我使用工具img2py.py,命令C:\Python27\Lib\site-packages\wx-3.0-msw\wx\tools>python img2py.py girl.bmp gi
rl.py,将图片转换为py程序,文件名:girl.py
2).新代码如下:
import wx
import girl #将图片程序导入
class PaintApp(wx.App):
def OnInit(self):
pic = girl.PyEmbeddedImage.GetBitmap()
bmp = wx.Image(pic).ConvertToBitmap()
wx.SplashScreen(bmp,wx.SPLASH_CENTER_ON_SCREEN | wx.SPLASH_TIMEOUT,2000,None,-1)
wx.Yield()
return True
问题:运行程序报错:
pic = girl.PyEmbeddedImage.GetBitmap()
TypeError: unbound method GetBitmap() must be called with PyEmbeddedImage instance as first argument (got nothing instead)
这个图片转换应该怎么写,代码bmp = wx.Image(pic).ConvertToBitmap(),pic这个参数该如何去定义?