def _wx_two_step_creation_on_classic(cls):
    """
    Patch the wxPython Classic class to behave like a wxPython
    Phoenix class on a 2-step creation process.

    On wxPython Phoenix, the first step is the parameterless
    ``__init__``, and the second step is the ``Create`` method with
    the construction parameters, e.g.::

        class CustomFrame(wx.Frame):
            def __init__(self, parent):
                super(CustomFrame, self).__init__() # 1st step
                # [...]
                self.Create(parent) # 2nd step
                # [...]

    On wxPython Classic, the same would be written as::

        class CustomFrame(wx.Frame):
            def __init__(self, parent):
                pre = wx.PreFrame() # 1st step
                # [... using "pre" instead of "self" ...]
                pre.Create(parent) # 2nd step
                self.PostCreate(pre) # "3rd step"
                # [...]
    """
    cls_init = cls.__init__
    cls_create = cls.Create

    @functools.wraps(cls_init)
    def __init__(self, *args, **kwargs):
        if args or kwargs:
            cls_init(self, *args, **kwargs)
        else: # 2-step creation
            new_self = getattr(wx, "Pre" + cls.__name__)()
            for pair in vars(new_self).items():
                setattr(self, *pair)

    if sys.platform == "win32":
        # On Windows, the wx.Pre*.Create constructors calls the
        # EVT_WINDOW_CREATE handler before returning (i.e, it processes
        # the event instead of just adding a message to the queue), and
        # that shouldn't happen before the PostCreate call in this thread
        @functools.wraps(cls_create)
        def create(self, *args, **kwargs):
            self.SetEvtHandlerEnabled(False)
            result = cls_create(self, *args, **kwargs)
            self.SetEvtHandlerEnabled(True)
            if result:
                self.PostCreate(self)
                wx.PostEvent(self, wx.WindowCreateEvent(self))
            return result
    else:
        @functools.wraps(cls_create)
        def create(self, *args, **kwargs):
            result = cls_create(self, *args, **kwargs)
            if result:
                self.PostCreate(self)
            return result

    cls.__init__ = __init__
    cls.Create = create
def _wx_two_step_creation_on_classic ( cls ) : cls_init = cls . __init__ cls_create = cls . Create @ functools . wraps ( cls_init ) def __init__ ( self , * args , ** kwargs ) : if args or kwargs : cls_init ( self , * args , ** kwargs ) else : new_self = getattr ( wx , "Pre" + cls . __name__ ) ( ) for pair in vars ( new_self ) . items ( ) : setattr ( self , * pair ) if sys . platform == "win32" : @ functools . wraps ( cls_create ) def create ( self , * args , ** kwargs ) : self . SetEvtHandlerEnabled ( False ) result = cls_create ( self , * args , ** kwargs ) self . SetEvtHandlerEnabled ( True ) if result : self . PostCreate ( self ) wx . PostEvent ( self , wx . WindowCreateEvent ( self ) ) return result else : @ functools . wraps ( cls_create ) def create ( self , * args , ** kwargs ) : result = cls_create ( self , * args , ** kwargs ) if result : self . PostCreate ( self ) return result cls . __init__ = __init__ cls . Create = create
Patch the wxPython Classic class to behave like a wxPython
    Phoenix class on a 2-step creation process.

    On wxPython Phoenix, the first step is the parameterless
    ``__init__``, and the second step is the ``Create`` method with
    the construction parameters, e.g.::

        class CustomFrame(wx.Frame):
            def __init__(self, parent):
                super(CustomFrame, self).__init__() # 1st step
                # [...]
                self.Create(parent) # 2nd step
                # [...]

    On wxPython Classic, the same would be written as::

        class CustomFrame(wx.Frame):
            def __init__(self, parent):
                pre = wx.PreFrame() # 1st step
                # [... using "pre" instead of "self" ...]
                pre.Create(parent) # 2nd step
                self.PostCreate(pre) # "3rd step"
                # [...]