wx.ToplevelWindow.SetIcon: Native MS Windows error dialog pops upin wxPython app, no exception raise

L

Laszlo Nagy

Hello,

I wrote a small program that works uses wxPython. The same application
works on Linux and Windows. When I start it from MS Windows, I see this
error message appearing each time I open a window:

---------------------------
Warehouseclient Error
---------------------------
Can't load image from file '': file does not exist.
---------------------------
OK
---------------------------


The message box itself is a native MS Windows dialog. Otherwise the
program works fine, just here is this annoying message. There is no
exception raised in the Python program. Nothing printed on console. I
figured out that this happens only when I set the icon of the window
using this code:

self.SetIcon(icon)

However, the error dialog is not displayed right after the SetIcon call
and no exception is raised. The dialog is displayed after __init__ has
been called, and probably before EVT_SHOW gets called. Documentation of
SetIcon
(http://wxwidgets.org/manuals/stable/wx_wxtoplevelwindow.html#wxtoplevelwindowseticon)
says that it is safe to delete the icon after calling this function. Now
here are the wreid things:

1. The icon is displayed correctly in the left top corner, so where is
the error?
2. The error message complains about a file. What has
wx.ToplevelFrame.SetIcon do with files?

I'm using: Windows XP Professional, Python 2.5, wxPython 2.8

Thanks,

Laszlo
 
K

kyosohma

Hello,

I wrote a small program that works uses wxPython. The same application
works on Linux and Windows. When I start it from MS Windows, I see this
error message appearing each time I open a window:

---------------------------
Warehouseclient Error
---------------------------
Can't load image from file '': file does not exist.
---------------------------
OK
---------------------------

The message box itself is a native MS Windows dialog. Otherwise the
program works fine, just here is this annoying message. There is no
exception raised in the Python program. Nothing printed on console. I
figured out that this happens only when I set the icon of the window
using this code:

self.SetIcon(icon)

However, the error dialog is not displayed right after the SetIcon call
and no exception is raised. The dialog is displayed after __init__ has
been called, and probably before EVT_SHOW gets called. Documentation of
SetIcon
(http://wxwidgets.org/manuals/stable/wx_wxtoplevelwindow.html#wxtoplev...)
says that it is safe to delete the icon after calling this function. Now
here are the wreid things:

1. The icon is displayed correctly in the left top corner, so where is
the error?
2. The error message complains about a file. What has
wx.ToplevelFrame.SetIcon do with files?

I'm using: Windows XP Professional, Python 2.5, wxPython 2.8

Thanks,

Laszlo

Normally I would recommend posting to the wxPython list, but it's down
at the moment. Keep an eye on their website as I'm sure they'll let
the community know when it's back up.

In the meantime, I'd look at how the demo does the icon displaying. It
looks like they created the icon they use using the img2py script
which basically creates a python file representation of the image.

See main.py of the Demo, line 1129. img2py is in the following default
location:
C:\Python24\Lib\site-packages\wx-2.8-msw-unicode\wxPython\tools

Without seeing how you create the image, it's hard to troubleshoot,
but I would guess that you have an absolute path that you're using in
your script that is different than what the exe is looking for.

Mike
 
L

Laszlo Nagy

See main.py of the Demo, line 1129. img2py is in the following default
location:
C:\Python24\Lib\site-packages\wx-2.8-msw-unicode\wxPython\tools
Without seeing how you create the image, it's hard to troubleshoot,
but I would guess that you have an absolute path that you're using in
your script that is different than what the exe is looking for.
I actually do have a wx.Icon instance loaded from a file. This problem
is not about loading a file into a wx.Icon instance. This why I'm
suprised about the message ("cannot load image file"). I already have
both the icon and the top level window in memory. If I comment out the

self.SetIcon(icon)

line in my code then there is no error message (and no icon on the
frame). The SetIcon method will call the Windows API at the end, and it
has nothing to do with files. It accepts a window handle and a pointer
to an icon resource. I cannot think about anything that would need to
read from a file while setting the icon of the frame. Moreover, the
icon is showing on the frame, looks like there is no error, so why am I
getting a message? It is not a python Exception, it pops out from
nowhere. :) I suspect it will be an internal error in wxWidgets or
wxPython. But their mailing list is not working. :-(

Thanks anyway.

Laszlo
 
K

kyosohma

I actually do have a wx.Icon instance loaded from a file. This problem
is not about loading a file into a wx.Icon instance. This why I'm
suprised about the message ("cannot load image file"). I already have
both the icon and the top level window in memory. If I comment out the

self.SetIcon(icon)

line in my code then there is no error message (and no icon on the
frame). The SetIcon method will call the Windows API at the end, and it
has nothing to do with files. It accepts a window handle and a pointer
to an icon resource. I cannot think about anything that would need to
read from a file while setting the icon of the frame. Moreover, the
icon is showing on the frame, looks like there is no error, so why am I
getting a message? It is not a python Exception, it pops out from
nowhere. :) I suspect it will be an internal error in wxWidgets or
wxPython. But their mailing list is not working. :-(

Thanks anyway.

Laszlo

I'm told the mailing list is now up. Sorry I wasn't more helpful.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top