Create a wxAuiMDIParentFrame from XRC

Hi all.

I was trying to create a wxAuiMDIParentFrame from XRC. My problem is
that it does not show up at all, without getting any error messages.
Here is a snippet from my code:

class StemFrame(wx.aui.AuiMDIParentFrame):
  def __init__(self):
    # Creation
    self.Pre = wx.aui.PreAuiMDIParentFrame()
    xrc.XmlResource.Get().LoadOnObject(self.Pre, None, "ID_FM_MAIN",
"wxAuiMDIParentFrame")
    self.PostCreate(self.Pre)

And here is a snippet from my XRC file:

<object class="wxAuiMDIParentFrame" name="ID_FM_MAIN">

<style>wxDEFAULT_FRAME_STYLE|wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX</style>
        <size>798,598</size>
        <title>AutoStem</title>
        <centered>1</centered>
        <icon>../art/autostem.ico</icon>

What have I done wrong? I tried writing an XmlResourceHandler for
wxAuiMDIParentFrame but GetInstance() did not return None in
DoCreateResource(), which makes me think that the window has somehow
already been created.

Thanki you for your help.

Regards,

Stavros

Tsolakos Stavros wrote:

What have I done wrong? I tried writing an XmlResourceHandler for
wxAuiMDIParentFrame but GetInstance() did not return None in
DoCreateResource(), which makes me think that the window has somehow
already been created.

There isn't a handler for that class already, so you will have to write your own for it. Please show us your handler class so we can see what went wrong.

http://wiki.wxpython.org/MakingSampleApps

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi.

Thank you for your reply.

There isn't a handler for that class already, so you will have to write
your own for it. Please show us your handler class so we can see what
went wrong.

Here is the code. It is very similar to the handler of wxFrame.

class wxAuiMDIParentFrameXmlHandler(xrc.XmlResourceHandler):
  def __init__(self):
    xrc.XmlResourceHandler.__init__(self)

    self.AddStyle("wxSTAY_ON_TOP", wx.STAY_ON_TOP)
    self.AddStyle("wxCAPTION", wx.CAPTION)
    self.AddStyle("wxDEFAULT_DIALOG_STYLE", wx.DEFAULT_DIALOG_STYLE)
    self.AddStyle("wxDEFAULT_FRAME_STYLE", wx.DEFAULT_FRAME_STYLE)
    self.AddStyle("wxSYSTEM_MENU", wx.SYSTEM_MENU)
    self.AddStyle("wxRESIZE_BORDER", wx.RESIZE_BORDER)
    self.AddStyle("wxCLOSE_BOX", wx.CLOSE_BOX)

    self.AddStyle("wxFRAME_NO_TASKBAR", wx.FRAME_NO_TASKBAR)
    self.AddStyle("wxFRAME_SHAPED", wx.FRAME_SHAPED)
    self.AddStyle("wxFRAME_TOOL_WINDOW", wx.FRAME_TOOL_WINDOW)
    self.AddStyle("wxFRAME_FLOAT_ON_PARENT", wx.FRAME_FLOAT_ON_PARENT)
    self.AddStyle("wxMAXIMIZE_BOX", wx.MAXIMIZE_BOX)
    self.AddStyle("wxMINIMIZE_BOX", wx.MINIMIZE_BOX)
    self.AddStyle("wxSTAY_ON_TOP", wx.STAY_ON_TOP)

    self.AddStyle("wxTAB_TRAVERSAL", wx.TAB_TRAVERSAL)
    self.AddStyle("wxWS_EX_VALIDATE_RECURSIVELY",
wx.WS_EX_VALIDATE_RECURSIVELY)
    self.AddStyle("wxFRAME_EX_METAL", wx.FRAME_EX_METAL)
    self.AddStyle("wxFRAME_EX_CONTEXTHELP", wx.FRAME_EX_CONTEXTHELP)

    self.AddWindowStyles()
    return

  def CanHandle(self, node):
    return self.IsOfClass(node, "wxAuiMDIParentFrame")

  def DoCreateResource(self):
    assert self.GetInstance() is None

    frame = wx.aui.AuiMDIParentFrame(self.GetParentAsWindow(),
            self.GetID(),
            self.GetText("title"),
            wx.DefaultPosition, wx.DefaultSize,
            self.GetStyle("style", wx.DEFAULT_FRAME_STYLE),
            self.GetName())

    if self.HasParam("size"):
      frame.SetClientSize(self.GetSize("size", frame))

    if self.HasParam("pos"):
      frame.Move(self.GetPosition())

    if self.HasParam("icon"):
      frame.SetIcon(self.GetIcon("icon", wx.ART_FRAME_ICON))

    self.SetupWindow(frame)

    self.CreateChildren(frame)

    if self.GetBool("centered", False):
      frame.Centre()

    return frame

Thank you very much.

Regards,

Stavros

Tsolakos Stavros wrote:

Hi.

Thank you for your reply.

There isn't a handler for that class already, so you will have to write
your own for it. Please show us your handler class so we can see what
went wrong.

Here is the code. It is very similar to the handler of wxFrame.

It looks correct to me. What problem were you having with it? How are you using it?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!