Explanation of PostCreate()

Could someone in the know please explain the intention of
PostCreate(). What happens when I call it, that kind of thing.
Or is it meant to be a hook which is called automatically by
Create() or some other mechanism?

What are some potential use-cases?

Thanks

···

--
Paul

Paul McNett wrote:

Could someone in the know please explain the intention of PostCreate(). What happens when I call it, that kind of thing. Or is it meant to be a hook which is called automatically by Create() or some other mechanism?

What are some potential use-cases?

When you use the "Pre" method to create a window instance so you can later call the Create method, there are a few hosekeeping things that are needed to fully link up the real class with the pre-created instance. PostCreate does that for you. For example:

class TestDialog(wx.Dialog):
     def __init__(
             self, parent, ID=-1, title="",
             size=wx.DefaultSize, pos=wx.DefaultPosition,
             style=wx.DEFAULT_DIALOG_STYLE
             ):
         pre = wx.PreDialog()
         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
         pre.Create(parent, ID, title, pos, size, style)
  self.PostCreate(pre)

It simply transfers the this and thisown attributes, and calls _setOORInfo and _setCallbackInfo if needed.

···

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

Robin Dunn wrote:

class TestDialog(wx.Dialog):
    def __init__(
            self, parent, ID=-1, title="",
            size=wx.DefaultSize, pos=wx.DefaultPosition,
            style=wx.DEFAULT_DIALOG_STYLE
            ):
        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)
    self.PostCreate(pre)

Oops, that last line should have been indented.

···

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

Robin Dunn writes:

It simply transfers the this and thisown attributes, and
calls _setOORInfo and _setCallbackInfo if needed.

Oh, okay, so I don't need to do that manually anymore. Thanks!

···

--
Paul