← Back to team overview

kicad-developers team mailing list archive

Python interface - what I can't find…

 

At the first some complains or wishes(expanding pcbnew/scripting/TODO.txt will
be nice)… :)
Well, most of my python/KiCAD scripting is to modify already existing projects.
This requires reading many specific information that at a later stage determine
a choose what should be changed and what shouldn't.
From the point of view of python, KiCAD swig implementation has many useless
methods that simply clutter created by doxygen documentation and it is difficult
with so such wholeness extract useful information. Bunch of tons useless stuff
as acquire(), own(), disown(), next()… If I think correct %ignore directive in
*.i files will be helpful.
in example pcbnew.LSET has useless :
>>> import pcbnew as brd
>>> example2.__swig_getmethods__.keys()
['AllCuMask', 'AllNonCuMask', 'Name', 'AllLayersMask', 'BackMask', 'AllTechMask', 'BackTechMask', 'FrontMask', 'InternalCuMask', 'FrontTechMask', 'UserMask']
If we had LSET already it's not necessary to create other LSET, proprietary
methods already exist in at the main pcbnew class:
>>> for methodName in dir(brd):
...     if methodName.startswith('LSET') and(methodName.endswith('Mask')):
...         print('pcbnew.'+methodName)
...
pcbnew.LSET_AllCuMask
pcbnew.LSET_AllLayersMask
pcbnew.LSET_AllNonCuMask
pcbnew.LSET_AllTechMask
pcbnew.LSET_BackMask
pcbnew.LSET_BackTechMask
pcbnew.LSET_FrontMask
pcbnew.LSET_FrontTechMask
pcbnew.LSET_InternalCuMask
pcbnew.LSET_UserMask
Python programmer is not interested in such intricacies as pointers to chars /
wxChars, strings here are ordinary sequence and all that unnecessary at python
level should be hidden and not included in doxygen docs.

After that, my real problem: - How get python string from in example
pcbnew.LSET_Name(0) ? IMHO that python wrapped method should directly return
Unicode string, any other is a mess.
>>> example = brd.LSET_Name(0)
>>> str(example)
"<Swig Object of type 'wxChar *' at 0x7fbc803c5870>"
>>> [methodName for methodName in dir(example) if not(methodName.startswith('__'))]
['acquire', 'append', 'disown', 'next', 'own']

--
Best Regards,
LordBlick