Just convert wxPGAttributeStorage to a dictionary

This commit is contained in:
Robin Dunn
2017-03-11 20:13:39 -08:00
parent c688fb0362
commit 094ab1f710
3 changed files with 47 additions and 8 deletions

View File

@@ -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',

View File

@@ -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

View File

@@ -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
};