可执行文件将不包括wxpython中使用的映像

2024-06-26 00:05:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python和wxpython创建了一个程序。我使用py2exe创建了一个可执行文件。它工作得很好,但我用我的公司标志作为喷溅屏幕和印刷图纸。我不得不移除splashscreen才能让可执行文件正常工作。在错误文本文件中,我得到以下信息:

Traceback (most recent call last): File "printGland.pyc", line 418, in OnPrintPage File "wx_gdi.pyc", line 3459, in DrawBitmap wx._core.PyAssertionError: C++ assertion "bmp.Ok()" failed at ....\src\msw\dc.cpp(1181) in wxDC::DoDrawBitmap(): invalid bitmap in wxDC::DrawBitmap

我假设bmp图像没有包含在可执行文件中。加载时代码是否有问题?在

 def __init__(self,parent,id):
    # Splash Screen
    image = wx.Image("Image.bmp",wx.BITMAP_TYPE_BMP)
    bmp = image.ConvertToBitmap()
    wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,1000,None,-1)
    wx.Yield()

或者是我在使用py2exe时应该添加到安装文件中的东西?有什么办法补救这种情况吗?在


Tags: inimage程序可执行文件linewxpythonfilepyc
2条回答

您必须确保在可执行文件所在的目录中包含该文件。如果你用它复制图像,它能工作吗?否则,您可以使用wxPython的img2py脚本将图像转换为Python文件并以这种方式打包。在

这有点过时:http://www.blog.pythonlibrary.org/2008/05/23/wxpython-embedding-an-image-in-your-title-bar/

这是文档页:http://wxpython.org/docs/api/wx.tools.img2py-module.html

{来自}

Is the image file present in the current working directory? You'll probably need to specify the path that the image file is located in rather than just assuming the CWD as you've given.

有关更多讨论,here。在

相关问题 更多 >