Christian Aichinger
2014-09-01 10:20:28 UTC
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 ----
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.
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.