Hi,
I get a segfault each time I try to set an icon to a wxDialog instance.
The icon file is valid, so I think I hit a bug.
Anyone have the same problem ?
The minimal code who segfault:
import wx
app = wx.App()
d = wx.MessageDialog(None, message=’’, caption=’’)
d.SetIcon(‘icon.ico’, wx.BITMAP_TYPE_ICO))
``
Because you need to pass an Icon type object, not a string:
http://wxpython.org/Phoenix/docs/html/TopLevelWindow.html#TopLevelWindow.SetIcon
First just make an icon object, then pass it to seticon:
ico = wx.Icon('icon.ico', wx.BITMAP_TYPE_ICO)
d.SetIcon(ico)
···
On Thursday, November 20, 2014 2:50:13 AM UTC-8, Kévin Bernard-Allies wrote:
Hi,
I get a segfault each time I try to set an icon to a wxDialog instance.
The icon file is valid, so I think I hit a bug.
Anyone have the same problem ?
The minimal code who segfault:
import wx
app = wx.App()
d = wx.MessageDialog(None, message=‘‘, caption=’’)
d.SetIcon(‘icon.ico’, wx.BITMAP_TYPE_ICO))
``
Exact, it’s a bad copy-paste of my part.
The code who doesn’t works is:
import wx
app = wx.App()
d = wx.MessageDialog(None, message=‘‘, caption=’’)
d.SetIcon(wx.Icon(‘icon.ico’, wx.BITMAP_TYPE_ICO))
``
These four lines in a python console give me a segfault every time.
···
Le jeudi 20 novembre 2014 19:24:33 UTC+1, Nathan McCorkle a écrit :
On Thursday, November 20, 2014 2:50:13 AM UTC-8, Kévin Bernard-Allies wrote:
Hi,
I get a segfault each time I try to set an icon to a wxDialog instance.
The icon file is valid, so I think I hit a bug.
Anyone have the same problem ?
The minimal code who segfault:
import wx
app = wx.App()
d = wx.MessageDialog(None, message=‘‘, caption=’’)
d.SetIcon(‘icon.ico’, wx.BITMAP_TYPE_ICO))
``
Because you need to pass an Icon type object, not a string:
http://wxpython.org/Phoenix/docs/html/TopLevelWindow.html#TopLevelWindow.SetIcon
First just make an icon object, then pass it to seticon:
ico = wx.Icon('icon.ico', wx.BITMAP_TYPE_ICO)
d.SetIcon(ico)
What version wxPython, Python and what OS?
This works fine for me on Windows 7 with wxPython 3.0.0.0-classic, fine on Windows XP with wxPython 2.9.4.0-msw (classic), and also fine on WinXP with wxPython 3.0.1-msw (classic):
import wx
print wx.version()
app = wx.App(False)
d = wx.MessageDialog(None,
"Do you really want to close this application?",
"Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
d.SetIcon(wx.Icon(‘icon.ico’, wx.BITMAP_TYPE_ICO))
d.ShowModal()
app.MainLoop()
···
On Friday, November 21, 2014 6:40:04 AM UTC-8, Kévin Bernard-Allies wrote:
Exact, it’s a bad copy-paste of my part.
The code who doesn’t works is:
import wx
app = wx.App()
d = wx.MessageDialog(None, message=‘‘, caption=’’)
d.SetIcon(wx.Icon(‘icon.ico’, wx.BITMAP_TYPE_ICO))
``
These four lines in a python console give me a segfault every time.
Python 2.7 on Ubuntu
wxPython 3.0.1.1 gtk2 (classic)
···
Le vendredi 21 novembre 2014 18:32:48 UTC+1, Nathan McCorkle a écrit :
On Friday, November 21, 2014 6:40:04 AM UTC-8, Kévin Bernard-Allies wrote:
Exact, it’s a bad copy-paste of my part.
The code who doesn’t works is:
import wx
app = wx.App()
d = wx.MessageDialog(None, message=‘‘, caption=’’)
d.SetIcon(wx.Icon(‘icon.ico’, wx.BITMAP_TYPE_ICO))
``
These four lines in a python console give me a segfault every time.
What version wxPython, Python and what OS?
This works fine for me on Windows 7 with wxPython 3.0.0.0-classic, fine on Windows XP with wxPython 2.9.4.0-msw (classic), and also fine on WinXP with wxPython 3.0.1-msw (classic):
import wx
print wx.version()
app = wx.App(False)
d = wx.MessageDialog(None,
"Do you really want to close this application?",
"Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
d.SetIcon(wx.Icon(‘icon.ico’, wx.BITMAP_TYPE_ICO))
d.ShowModal()
app.MainLoop()
Ok, just tried the code I posted here on an Ubuntu OS (14.04) with wxPython 3.0.1.1 gtk2 (classic) which I compiled from source a month or two ago. I installed the faulthandler module and enabled it prior to pasting the code into the Python interpreter and here’s what I got:
Fatal Python error: Segmentation fault
Current thread 0x00007f60b338a740 (most recent call first):
File “/usr/local/lib/python2.7/dist-packages/wx/_windows.py”, line 435 in SetIcon
File “”, line 1 in
Segmentation fault (core dumped)
and I checked that line 435 in _windows.py and it is the return call line here:
434 def SetIcon(*args, **kwargs):
434 “”“SetIcon(self, Icon icon)”“”
435 return windows.TopLevelWindow_SetIcon(*args, **kwargs)
···
On Tuesday, November 25, 2014 3:09:34 AM UTC-8, Kévin Bernard-Allies wrote:
Python 2.7 on Ubuntu
wxPython 3.0.1.1 gtk2 (classic)
Thank you for your help.
I’ve tested with a Gentoo. The wxpython package from Gentoo don’t segfault.
But when using the source, I’ve got the same result.
The last source version allows us to use GTK3, so I’ve tested with it: no more segfault, but an assertion failed:
Traceback (most recent call last):
File “”, line 1, in
File “wx/_windows.py”, line 435, in SetIcon
return windows.TopLevelWindow_SetIcon(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion “(m_widget != NULL)” failed at /data/Projects/wxtest/wxPython-src-3.0.2.0/src/gtk/toplevel.cpp(1377) in SetIcons(): invalid frame
``
I will post a bug on the bug tracker.
···
Le mardi 25 novembre 2014 18:13:45 UTC, Nathan McCorkle a écrit :
On Tuesday, November 25, 2014 3:09:34 AM UTC-8, Kévin Bernard-Allies wrote:
Python 2.7 on Ubuntu
wxPython 3.0.1.1 gtk2 (classic)
Ok, just tried the code I posted here on an Ubuntu OS (14.04) with wxPython 3.0.1.1 gtk2 (classic) which I compiled from source a month or two ago. I installed the faulthandler module and enabled it prior to pasting the code into the Python interpreter and here’s what I got:
Fatal Python error: Segmentation fault
Current thread 0x00007f60b338a740 (most recent call first):
File “/usr/local/lib/python2.7/dist-packages/wx/_windows.py”, line 435 in SetIcon
File “”, line 1 in
Segmentation fault (core dumped)
and I checked that line 435 in _windows.py and it is the return call line here:
434 def SetIcon(*args, **kwargs):
434 “”“SetIcon(self, Icon icon)”“”
435 return windows.TopLevelWindow_SetIcon(*args, **kwargs)