From 0d23d74d72a83c077322da7b280bfb0fa25afdbc Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 21 Feb 2017 12:45:10 -0800 Subject: [PATCH] Add code to auto convert from string or wxPGProperty to wxPGPropArgCls --- etg/propgridiface.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/etg/propgridiface.py b/etg/propgridiface.py index 0b965a04..a50ed6c8 100644 --- a/etg/propgridiface.py +++ b/etg/propgridiface.py @@ -34,7 +34,31 @@ def run(): c = module.find('wxPGPropArgCls') assert isinstance(c, etgtools.ClassDef) + c.find('wxPGPropArgCls').findOverload('deallocPtr').ignore() c.find('GetPtr').overloads[0].ignore() + c.convertFromPyObject = """\ + // Code to test a PyObject for compatibility with wxPGPropArgCls + if (!sipIsErr) { + if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)) + return TRUE; + if (sipCanConvertToType(sipPy, sipType_wxPGProperty, SIP_NO_CONVERTORS)) + return TRUE; + return FALSE; + } + + // Code to convert a compatible PyObject to a wxPGPropArgCls + if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)) { + *sipCppPtr = new wxPGPropArgCls(Py2wxString(sipPy)); + return sipGetState(sipTransferObj); + } + else { + wxPGProperty* prop = reinterpret_cast( + sipConvertToType(sipPy, sipType_wxPGProperty, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); + *sipCppPtr = new wxPGPropArgCls(prop); + return sipGetState(sipTransferObj); + } + """ + c = module.find('wxPropertyGridInterface') c.abstract = True