|
List Info
Thread: Native Windows error message after SetIcon(), no python exception raised
|
|
| Native Windows error message after
SetIcon(), no python exception raised |
  Hungary |
2007-09-14 02:14:56 |
Hello,
I wrote a small program that 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. The wx.Icon
instance and the wx.Frame instance are already in memory
when I call SetIcon. What it has to do with any file?
Test environment was: Windows XP Professional, Python 2.5,
wxPython 2.8
Thanks,
Laszlo
------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribe lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help lists.wxwidgets.org
|
|
| Re: Native Windows error message after
SetIcon(), no python exception raised |
  Hungary |
2007-09-17 11:26:06 |
>
>
>> 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. The
wx.Icon instance and
>> the wx.Frame instance are already in memory when I
call SetIcon. What
>> it has to do with any file?
>
> How do you load the icon?
>
First I load a PIL image from a png file and convert it to a
wx.Image.
Then I store the bitmap in a wx.ImageList instance (actually
a
descendant but I hope it doesn't matter). This descendant
has a GetIcon
method:
def GetIcon(self,name):
bmp = self.copybitmap(name)
return imagetools.bitmaptoicon( bmp )
The copytobitmap method uses wx.BitmapFromImage to create a
wx.Bitmap
from the wx.Image. (The original wx.Image was loaded from a
png file,
the resulting bitmap will have a mask assigned, but I hope
this is not
related to the problem.)
Finally, here is the bitmaptoicon function:
def bitmaptoicon(bmp):
"""Convert wx.Bitmap to wx.Icon.
NOTE: The bitmap should already have a mask assigned.
param bmp: A wx.Bitmap instance
"""
ico = wx.Icon('',bmp.GetWidth(),bmp.GetHeight())
ico.CopyFromBitmap(bmp)
return ico
Thanks,
Laszlo
------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribe lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help lists.wxwidgets.org
|
|
| Re: Native Windows error message after
SetIcon(), no python exception raised |
  United States |
2007-09-17 12:00:00 |
Probably unrelated to you problem, but...
Laszlo Nagy wrote:
> First I load a PIL image from a png file and convert it
to a wx.Image.
Why not just load it directly into wx.Image from the PNG?
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker noaa.gov
------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribe lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help lists.wxwidgets.org
|
|
| Re: Native Windows error message after
SetIcon(), no python exception raised |
  Hungary |
2007-09-17 12:33:50 |
Christopher Barker wrote:
> Probably unrelated to you problem, but...
>
> Laszlo Nagy wrote:
>> First I load a PIL image from a png file and
convert it to a wx.Image.
>
> Why not just load it directly into wx.Image from the
PNG?
It is because this custom imagelist can resize the images to
the same
size before adding them to the list. wx.Image can also
resize images,
but not with antialias. This is why I use PIL.
Laszlo
------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribe lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help lists.wxwidgets.org
|
|
| Re: Native Windows error message after
SetIcon(), no python exception raised |
  United States |
2007-09-17 17:22:33 |
Laszlo Nagy wrote:
>
> Finally, here is the bitmaptoicon function:
>
> def bitmaptoicon(bmp):
> """Convert wx.Bitmap to wx.Icon.
> NOTE: The bitmap should already have a mask
assigned.
> param bmp: A wx.Bitmap instance
> """
> ico = wx.Icon('',bmp.GetWidth(),bmp.GetHeight())
This is where the problem is coming from. You are using the
load-from-file constructor but are not supplying a
filename.
> ico.CopyFromBitmap(bmp)
> return ico
You can use this instead:
ico = wx.IconFromBitmap(bmp)
return ico
--
Robin Dunn
Software Craftsman
http://wxPython.org Java
give you jitters? Relax with wxPython!
------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribe lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help lists.wxwidgets.org
|
|
| Re: SOLVED Native Windows error message
after SetIcon(), no python exception
raised |
  Hungary |
2007-09-18 08:00:44 |
Robin Dunn wrote:
>> ico =
wx.Icon('',bmp.GetWidth(),bmp.GetHeight())
>
> This is where the problem is coming from. You are
using the
> load-from-file constructor but are not supplying a
filename.
Great. Thank you! I tried wx.IconFromBitmap and it worked.
But I still
do not understand what is happening here.
>
>> ico.CopyFromBitmap(bmp)
>> return ico
If the constructor fails, then it should raise a Python
exception. At
least this is what I would expect. But it returns a (half
initialized?)
instance. I would like to understand.
BTW I figured out something: I used wxPython 2.6 on Ubuntu
and 2.8 on
Windows. The 2.6 version works with the above code, 2.8 does
not.
>
>
> You can use this instead:
>
> ico = wx.IconFromBitmap(bmp)
> return ico
>
Thanks again,
Laszlo
------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribe lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help lists.wxwidgets.org
|
|
| Re: SOLVED Native Windows error message
after SetIcon(), no python exception
raised |
  United States |
2007-09-18 18:30:13 |
Laszlo Nagy wrote:
> Robin Dunn wrote:
>>> ico =
wx.Icon('',bmp.GetWidth(),bmp.GetHeight())
>>
>> This is where the problem is coming from. You are
using the
>> load-from-file constructor but are not supplying a
filename.
> Great. Thank you! I tried wx.IconFromBitmap and it
worked. But I still
> do not understand what is happening here.
>
>
>>
>>> ico.CopyFromBitmap(bmp)
>>> return ico
> If the constructor fails, then it should raise a Python
exception. At
> least this is what I would expect. But it returns a
(half initialized?)
> instance. I would like to understand.
The C++ code is not reporting an error to the Python layers,
so it
doesn't know it should raise an exception. Instead the C++
code is just
logging the problem.
>
> BTW I figured out something: I used wxPython 2.6 on
Ubuntu and 2.8 on
> Windows. The 2.6 version works with the above code, 2.8
does not.
Probably it's because the Ubuntu version is compiled without
the debug
flag turned on and so the log message is never logged
there.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java
give you jitters? Relax with wxPython!
------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribe lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help lists.wxwidgets.org
|
|
[1-7]
|
|