← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] additions/fix to python interface

 

Hey Miles,

Thank you for your interest in contributing to KiCad.  We can always use
the help with the Python scripting support.  Your KiCad python scripting
blog looks interesting.  If you don't mind, I would like to link to it
from the KiCad website.  I think it would be a beneficial resource for
KiCad users.

One thing that you may or may not be aware of is that the current python
support is very raw and low level.  Since you can directly access
objects within the current board editing session, you can cause pcbnew
to crash if you are not careful.  We have discussed wrapping some of
this with python helper code to prevent this but to my knowledge, no one
has done any work on this front.

I pushed your patch with some minor coding and commit message policy
fixes.  For future reference we have a coding policy[1] for C++ code (.h
and .cpp file) and a commit message format policy[2].  Since this is
your first patch, you get a free pass but for future patches please
follow these policies.  As for the swig files, please try to keep the
same coding format as the current files.  At some point we should
probably include them along with our python scripts in the coding policy
as well.  Thank you for your contribution to KiCad and I look forward to
working with you in the future.

Cheers,

Wayne

[1]:
http://docs.kicad-pcb.org/doxygen/md_Documentation_development_coding-style-policy.html
[2]: http://docs.kicad-pcb.org/doxygen/commit_messages.html

On 3/17/2017 4:03 AM, miles mccoo wrote:
> 
> 
> Hello,
> 
> This is the first patch I'm submitting to Kicad. Hopefully, I'm
> following the directions correctly.
> 
> My interest is in pcbnew's python interface and this patch adds/fixes a
> couple things
> 
>   * EDA_RECT.Inflate takes a wxCoord as an argument. swig didn't know
>     that wxCoord is just an int. I've added a typedef to wx.i. wxCoord
>     is defined in include/wx/defs.h
>   * Within the C code, frames, toolbars and such are identified using an
>     enum in id.h. To expose those names to the python interface, I've
>     added include "id.h" to pcbnew.i
>   * There doesn't appear to be a good way from python to ask pcbnew to
>     Refresh the screen or to Zoom to a specific area. So I've added
>     Refresh and WindowZoom to pcbnew_scripting_helpers
> 
> 
> 
> 
> Since this is also my first post to this mail list, a couple words about
> myself...
> 
> Perhaps of most immediate interest to you is a blog I've started
> recently explaining how to use pcbnew's scripting
> abilities: https://kicad.mmccoo.com/kicad-scripting-table-of-contents/.
> I haven't found much documentation about how to do scripting in pcbnew,
> so hopefully you'll find it useful.
> 
> Until a year and a half ago, I spent many years working on VLSI EDA
> tools for a major CPU manufacture whose name starts with In and ends
> with tel. Not quite PCB, but...
> 
> Going forward, I hope to contribute more enhancements to pcbnew's python
> stuff. The layout tools used by my former employer included many, many
> features written in TCL. In the PCB realm, I'd like to help enable
> something similar in Kicad.
> 
> Miles
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 



References