I have written a few plugins for KiCad using a painful setup not much different from typing into IDLE. I would like to do a lot more sophisticated work, which requires a better setup.
I am looking for guidance setting-up a solid Python/KiCad development environment under Windows 10, preferably using Pycharm Professional or VSCode if necessary. Any articles or posts I’ve been able to find on the subject are pre KiCad 6.
Just point your VSCode to python.exe inside kicad’s bin folder. It should do the rest easily. Similarly in pycharm/idea add a python environment by pointing to existing installation and select python in kicad’s folder.
I described this process with a few more details here: Getting started using Python Scripts - #8 by qu1ck
It’s for kicad 5 but same works for 6.
Similarly for VSCode press Ctrl-P and run “Python select interpreter” command.
As you can see I have selected here python from nightly build of kicad but you can enter any path.
VSCode will then parse pcbnew module as it’s on pythonpath for that interpreter.
Just got around to looking at this. BTW, the keyboard shortcut in VSCode is Ctrl+Shift+P. Also, it did not surface the KiCad interpreter, just other Python interpreters I have on the machine. I just pasted the path by hand in Settings. Will mess with it some more in the coming weeks. Not sure if I need to make VSCode aware of wxPython and other libraries. Will figure it out.
pcbnew module is not strongly typed because it’s generated by swig.
Help out your IDE by explicitly specifying types: board: pcbnew.BOARD = pcbnew.GetBoard()
or python2 style board = pcbnew.GetBoard() # type: pcbnew.BOARD
What were you hoping to do with this syntactically wrong Python statement?
The . indicates what should follow the class instance is either an attribute which is an identifier, or a class method, like in the previous statement.
However { starts a dict literal, and what’s more, it should contain key-value pairs separated by a colon.