problems with wx.SplashScreen

I'm trying to set up a splashscreen for my app. I am calling a
monochrome WINDOWS bmp file and I get an error message. The error
messages are different depending on whether I comment out this line:
bmp = image.ConvertToBitmap()

I am working with PortablePython (the PYTHON 2.5 version). I am using
wxPYTHON version 2.8.8.1. The machine that I am currently using for
development is a VISTA machine but the target is an XP platform.

Here is the code of a small test program that I wrote. The code is
exactly the same as in my program and the error messages are the same:

import wx
if __name__ == '__main__':
    pr = wx.PySimpleApp()
    image = wx.Image("honeysuckle.bmp",wx.BITMAP_TYPE_BMP)
    bmp = image.ConvertToBitmap()
    wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,
15000,None,-1)
    wx.Yield()

I wrote the code based on the example in 'wxPYTHON in Action' by
Rappin and Dunn.

When I leave the line mentioned above uncommented, I get this error
message:

  File "splashTest01.py", line 5, in <module>
    bmp = image.ConvertToBitmap()
  File "E:\PortablePython1.0\lib\site-packages\wx\_core.py", line
3340, in ConvertToBitmap
wx._core.PyAssertionError: C++ assertion "image.Ok()" failed at ..\..
\src\msw\bitmap.cpp(799) in wxBitmap::CreateFromImage(): invalid image

If I comment out that line and change 'image =' to 'bmp =', I get this
error message:

Traceback (most recent call last):
  File "splashTest01.py", line 6, in <module>
    wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,
15000,None,-1)
  File "E:\PortablePython1.0\lib\site-packages\wx\_windows.py", line
836, in __init__
TypeError: in method 'new_SplashScreen', expected argument 1 of type
'wxBitmap const &'

I would appreciate any suggestions you might have.

BP wrote:

I'm trying to set up a splashscreen for my app. I am calling a
monochrome WINDOWS bmp file and I get an error message. The error
messages are different depending on whether I comment out this line:
bmp = image.ConvertToBitmap()

I am working with PortablePython (the PYTHON 2.5 version). I am using
wxPYTHON version 2.8.8.1. The machine that I am currently using for
development is a VISTA machine but the target is an XP platform.

Here is the code of a small test program that I wrote. The code is
exactly the same as in my program and the error messages are the same:

import wx
if __name__ == '__main__':
    pr = wx.PySimpleApp()
    image = wx.Image("honeysuckle.bmp",wx.BITMAP_TYPE_BMP)
    bmp = image.ConvertToBitmap()
    wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,
15000,None,-1)
    wx.Yield()

I wrote the code based on the example in 'wxPYTHON in Action' by
Rappin and Dunn.

When I leave the line mentioned above uncommented, I get this error
message:

  File "splashTest01.py", line 5, in <module>
    bmp = image.ConvertToBitmap()
  File "E:\PortablePython1.0\lib\site-packages\wx\_core.py", line
3340, in ConvertToBitmap
wx._core.PyAssertionError: C++ assertion "image.Ok()" failed at ..\..
\src\msw\bitmap.cpp(799) in wxBitmap::CreateFromImage(): invalid image

The image failed to load. Is it a valid image file? Since you don't specify the full path name, is is located in the current working directory of the running application?

···

--
Robin Dunn
Software Craftsman

BP wrote:

Yes to both questions. It was a file made with WINDOWS PAINT (I
figured that it can't get more canonical than that) and it is in the
same folder as the program.

That's not quite what I asked you. Just because the program is in a folder does not mean that is the current working directory when the program is running. It depends on how it was launched and whether the program does anything to change to another folder while it is running.

Try doing this just to verify what the working directory is before you load the image file:

  import os
  print os.getcwd()

If it is the right folder then there is probably something wrong with the image file. You might want to try converting it to some other format.

···

--
Robin Dunn
Software Craftsman