Discussion:
Phoenix + XRC + Subclassing
Christian Aichinger
2014-09-01 10:20:28 UTC
Permalink
Hi!
I ran into a problem trying to subclass a wx.Panel when using XRC on
Python 3.3/Windows 7.

In my application, the window creation just aborts without further
message or error indication. In a simplified testcase (included below)
Python crashes with an access violation.

The exact subclass doesn't seem to matter, with the same result when
setting it to xrc_testcase.SubclassedPanel1,
xrc_testcase.SubclassedPanel2, or even wx.Panel itself.

Am I doing subclassing wrong or is this a bug with the interaction of
Phoenix with the C++ engine?

Best wishes,
Chris

---- Begin xrc_testcase.py ----
#!/usr/bin/python3.3

import wx
import wx.xrc as xrc

xrc_data = """
<?xml version="1.0" encoding="UTF-8"?>
<resource>
<object class="wxFrame" name="MainFrame">
<object class="wxPanel" name="MainPanel"
subclass="xrc_testcase.SubclassedPanel2">
<object class="wxTextCtrl" name="ItemTitleTextCtrl"/>
</object>
<title>Phoenix XRC Subclass Test</title>
<style>wxDEFAULT_FRAME_STYLE|wxCAPTION|wxSYSTEM_MENU</style>
</object>
</resource>
"""

class SubclassedPanel1(wx.Panel):
pass

class SubclassedPanel2(wx.Panel):
def __init__(self, *args, **kwargs):
print("SubclassedPanel2.__init__", args, kwargs)
wx.Panel.__init__(self)
# Can't explicitly call self.Create() here, since we don't
# have our parent at this time.

def Create(self, *args, **kwargs):
print("SubclassedPanel2.Create", args, kwargs)
wx.Panel.Create(self, *args, **kwargs)

class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self)
res = xrc.XmlResource()
res.LoadFromString(xrc_data.strip().encode('utf-8'))
# 3-argument LoadFrame() calls self.Create(), so don't call it
# explicitly here.
if not res.LoadFrame(self, None, "MainFrame"):
raise RuntimeError("Could not load main frame from XRC")

if __name__ == '__main__':
app = wx.App()
frame = MainFrame()
frame.Show(True)
app.MainLoop()

---- Endxrc_testcase.py ----
--
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-02 23:04:07 UTC
Permalink
I am not sure, but you could try importing the faulthandler module to gain
some more info on the crash:
https://pypi.python.org/pypi/faulthandler/
Post by Christian Aichinger
Hi!
I ran into a problem trying to subclass a wx.Panel when using XRC on
Python 3.3/Windows 7.
In my application, the window creation just aborts without further
message or error indication. In a simplified testcase (included below)
Python crashes with an access violation.
The exact subclass doesn't seem to matter, with the same result when
setting it to xrc_testcase.SubclassedPanel1,
xrc_testcase.SubclassedPanel2, or even wx.Panel itself.
Am I doing subclassing wrong or is this a bug with the interaction of
Phoenix with the C++ engine?
Best wishes,
Chris
---- Begin xrc_testcase.py ----
#!/usr/bin/python3.3
import wx
import wx.xrc as xrc
xrc_data = """
<?xml version="1.0" encoding="UTF-8"?>
<resource>
<object class="wxFrame" name="MainFrame">
<object class="wxPanel" name="MainPanel"
subclass="xrc_testcase.SubclassedPanel2">
<object class="wxTextCtrl" name="ItemTitleTextCtrl"/>
</object>
<title>Phoenix XRC Subclass Test</title>
<style>wxDEFAULT_FRAME_STYLE|wxCAPTION|wxSYSTEM_MENU</style>
</object>
</resource>
"""
pass
print("SubclassedPanel2.__init__", args, kwargs)
wx.Panel.__init__(self)
# Can't explicitly call self.Create() here, since we don't
# have our parent at this time.
print("SubclassedPanel2.Create", args, kwargs)
wx.Panel.Create(self, *args, **kwargs)
wx.Frame.__init__(self)
res = xrc.XmlResource()
res.LoadFromString(xrc_data.strip().encode('utf-8'))
# 3-argument LoadFrame() calls self.Create(), so don't call it
# explicitly here.
raise RuntimeError("Could not load main frame from XRC")
app = wx.App()
frame = MainFrame()
frame.Show(True)
app.MainLoop()
---- Endxrc_testcase.py ----
--
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...