[python API] Pcbnew find which module (if any) is selected


#1

I am starting to fiddle with python scripting in pcbnew and I can’t seem to find if there is a way to find which module (f any) is selected in pcbnew from phyton scripting console?

I’ve found a class MODULE_List with method IsSelected but I don’t know how to use it. It is highly likely that the problem is with me as I have a weak background in OO programing.

Any help will be appreciated.


#2

You might be able to use KiCommand instead of python. If you need example code, KiCommand has lots in the python code.

In python:

selectedmodules = filter(lambda x: x.IsSelected(),pcbnew.GetBoard().GetModules())

#3

Woa this was fast. Thank you very much.

I’ll certainly look at KiCommand, but mostly as a code example, as I am trying to put a GUI around replicatelayout.py.


#4

For a GUI, look at wxFormBuilder.

There is code in KiCommand to create a dockable window (and in LayerViewSet as well).

Good luck!!