← Back to team overview

kicad-developers team mailing list archive

Re: Will realy next stable release be really full useful?

 

On Fri, Jul 10, 2015 at 07:36:27PM +0200, LordBlick wrote:
> I insisted that Python scripting is just a toy, a lot of features aimed to
> return text, returns some mythical pointers that are nonsense.
> It will be nice to have global function pcbnew.GetChars(), which will give
> something usable from any 'wxChar *' or 'wxString *'.
> Asking for improving each encountered case is beyond my strength.
> >>> import pcbnew as brd
> >>> brd.ColorGetName(0)
> <Swig Object of type 'wxChar *' at 0x7fad80105480>
> Of course I might deal with ctypes, but I would assume that this is 
> not necessary.
> >>> import ctypes as ct
> >>> ct.wstring_at(brd.ColorGetName(0).__long__())
> u'Black'

Because the pcbnew module is just a SWIG wrapper around the internal 
functions. I'm not personally convinced that's useful - IMO there needs 
to be a further wrapper around that, that converts the interface into 
something more "Pythonic". Get rid of the C++-style getters and setters, 
add proper iterators, etc. But... it is what it is, that's why it does 
that.

> BTW. Why received string is not compatible with std name space?:
> >>> ct.wstring_at(brd.ColorGetName(16).__long__())
> u'Magenta 2'
> >>> for attr_name in dir(brd):
> ...   if 'magenta' in attr_name.lower():
> ...     print("pcbnew.%s:%i" % (attr_name, getattr(brd, attr_name)))
> ...
> pcbnew.DARKMAGENTA:10
> pcbnew.LIGHTMAGENTA:22
> pcbnew.MAGENTA:16
> pcbnew.PUREMAGENTA:28

Because you specifically chose to call the function whose purpose is to 
return the UI display names of the colors.

By the way, I really don't understand your subject line. KiCad's been 
useful for years without a Python interpreter, why would this mean the 
stable release isn't useful?

--
Chris


Follow ups

References