I have created a program using python and wxpython. I have created an executable file using py2exe. IT is working fine but I had used my company logo as a splashscreen and in the printed drawings. I had to remove the splashscreen to get the executable file to work. In the error text file I get the following:
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
I'm assuming the bmp image has not been included in the executable file. Is there something wrong with the code when it is loaded?
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()
Or is it something I should have added to the setup file when I used py2exe? Any ideas on how to remedy the situation?
You'll have to make sure you include the file in the same directory as your executable. If you copy the image in with it, does it work? Otherwise, you can use wxPython's img2py script to turn your image into a Python file and bundle it in that way.
This is slightly out of date: http://www.blog.pythonlibrary.org/2008/05/23/wxpython-embedding-an-image-in-your-title-bar/
And here's the doc page: http://wxpython.org/docs/api/wx.tools.img2py-module.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.