From 094ab1f710c58b176d7473793b5926ebbdf1f7f3 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 11 Mar 2017 20:13:39 -0800 Subject: [PATCH] Just convert wxPGAttributeStorage to a dictionary --- etg/_propgrid.py | 1 + etg/propgridproperty.py | 8 ------- src/pgattributestorage.sip | 46 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 src/pgattributestorage.sip diff --git a/etg/_propgrid.py b/etg/_propgrid.py index 706b2cc9..245577ac 100644 --- a/etg/_propgrid.py +++ b/etg/_propgrid.py @@ -24,6 +24,7 @@ ITEMS = [ ] # included as part of this module. These should all be items that are put in # the wxWidgets "propgrid" library in a multi-lib build. INCLUDES = [ 'pgvariant', + 'pgattributestorage', 'propgriddefs', 'propgridproperty', 'propgrideditors', diff --git a/etg/propgridproperty.py b/etg/propgridproperty.py index 719b1450..23fa8c30 100644 --- a/etg/propgridproperty.py +++ b/etg/propgridproperty.py @@ -22,7 +22,6 @@ ITEMS = [ 'wxPGPaintData', 'wxPGDefaultRenderer', 'wxPGCellData', 'wxPGCell', - 'wxPGAttributeStorage', 'wxPGProperty', 'wxPropertyCategory', @@ -51,13 +50,6 @@ def run(): c.bases = ['wxRefCounter'] - c = module.find('wxPGAttributeStorage') - # TODO: Add methods to add a Python iterator using these methods - c.find('StartIteration').ignore() - c.find('GetNext').ignore() - c.find('const_iterator').ignore() - - c = module.find('wxPGProperty') tools.ignoreConstOverloads(c) c.find('StringToValue.variant').out = True diff --git a/src/pgattributestorage.sip b/src/pgattributestorage.sip new file mode 100644 index 00000000..d9b00fc0 --- /dev/null +++ b/src/pgattributestorage.sip @@ -0,0 +1,46 @@ +//-------------------------------------------------------------------------- +// Name: pgattributestorage.sip +// Purpose: MappedType for wxPGAttributeStorage +// +// Author: Robin Dunn +// +// Created: 11-March-2017 +// Copyright: (c) 2017 by Total Control Software +// Licence: wxWindows license +//-------------------------------------------------------------------------- + + + +%MappedType wxPGAttributeStorage +{ + %ConvertToTypeCode + // Code to test a PyObject for compatibility. + if (!sipIsErr) { + // Currently this is output only, so just reject everything + return FALSE; + } + + // Code to create a new wxVariant from the PyObject + // ... + return sipGetState(sipTransferObj); + %End + + + %ConvertFromTypeCode + // Code to convert to a PyObject. + wxPGAttributeStorage::const_iterator it = sipCpp->StartIteration(); + wxVariant v; + + PyObject* dict = PyDict_New(); + if ( !dict ) return dict; + + while ( sipCpp->GetNext( it, v ) ) { + const wxString& name = v.GetName(); + PyObject* pyStr = wx2PyString(name); + PyObject* pyVal = wxPGVariant_out_helper(v); + int res = PyDict_SetItem( dict, pyStr, pyVal ); + } + return dict; + %End +}; +