← Back to team overview

kicad-developers team mailing list archive

Re: more pythonic scripting API for pcbnew

 

On 7 January 2015 at 10:36, PTT <ptt@xxxxxxxxxxxxx> wrote:
> Dear all,
> First of all thanks for all the good work, I recently switched to KiCAD
> because of the added scripting support which I needed for scripted button
> placement on a pcb.
>
> To make it easier to get my work done I made some convenience functions and
> classes wrapping the swig api to have a cleaner interface.
>
> Please have a look and see if it is useful to somehow incorporate it in the
> main branch.
>
> pcbnew_easy.py
> https://gist.github.com/pierstitus/7be2d9923da502c88ff1
>
> There is a simple usage example, to run put the file on your path, (or add
> the path with sys.path.append("...path_to_file..."))
> open the pcbnew console and enter
>>>> import pcbnew_easy
>>>> pcbnew_easy.test()
> (the screen is only updating on moving)
>
> Piers
>

Hi Piers,

Certainly, the python interface we expose should be much more pythonic, I agree!

It will help us to have an abstraction layer too between the python
API and the internal C++ structures and API. Changing the C++ API
shouldn't require all scripts to be re-written, unless we move KiCad's
internals to an official API. I'd rather the API definition be defined
by a secondary python module that sits atop the KiCad internals which
can be more fluid.

I think we could do with some people more familiar than me with python
to take this on in a public repo somewhere and collaborate on it to
make a more python interface. Forward internal data change requests
and requests for exposure of more internals to the KiCad development
list (this one), or send patches to the swig interface files.

We could also have a more python interface by have much more advances
swig interface files, that's also an avenue someone could investigate,
but I find the SWIG interface file language quite awful.

Whatever route we take to make the scripting more pythonic, it'll need
multiple developers to be able to support it alongside the C++
development.

Thank-you for broaching the subject and providing some code, it's
really interesting to see. It looks like there's some good interest in
it.

These are just my views of course! :-D

Best Regards,

Brian.


References