I’m unable to get it to work. I struggle to get the plugin to load at all. And since KiCad gives no feedback I don’t know where the issue is. I think I have done it the same way it was done it the examples, but I don’t see the icon in the toolbar.
KiCad detects my addon. I can see that because a wrong identifier
triggers an error. With the correct identifier nothing happens. Nothing shows up in KiCad and I have no real way of debugging it. What I did:
Created a requirements.txt in the coilgen plugin root folder
kicad-python>=0.1.0
wxPython~=4.2
Created a plugin.json in the coilgen plugin root folder
{
"identifier": "coilgen",
"name": "PCB Coil Generator",
"description": "Generates ...",
"runtime": {
"type": "python",
"min_version": "3.11"
},
"actions": [
{
"identifier": "coilgen",
"name": "PCB Coil Generator",
"description": "Generates ...",
"show-button": true,
"scopes": [
"pcb"
],
"entrypoint": "coilgen.py",
"icons-light": [
"icon.png"
]
}
]
}
Replaced the old plugin init with the new way
old __init__.py
:
try:
from .plugin import Plugin
plugin = Plugin()
plugin.register()
except Exception as e:
import logging
logger = logging.getLogger()
logger.debug(repr(e))
old Plugin
class in main file:
class Plugin(pcbnew.ActionPlugin):
def __init__(self):
self.name = "Coil Generator"
self.category = "Manufacturing"
self.description = "Toolkit to automatically generate coils for KiCad"
self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
self.show_toolbar_button = True
self.icon_file_name = os.path.join(os.path.dirname(__file__), 'icon.png')
self.dark_icon_file_name = os.path.join(os.path.dirname(__file__), 'icon.png')
def Run(self):
# Assuming the PCBNew window is focused when run function is executed
# Alternative would be to keep track of last focussed window, which does not seem to work on all systems
CoilGeneratorUI(wx.Window.FindFocus()).Show()
new initialization in main file:
if __name__ == "__main__":
app = wx.App()
coilgen = CoilGeneratorUI(wx.Window.FindFocus())
coilgen.Show()
app.MainLoop()
coilgen.Destroy()
Here’s a current draft PR to see the changes I did: Update to KiCad 9 Python API by TimGoll · Pull Request #17 · DIaLOGIKa-GmbH/kicad-coil-creator · GitHub
I want to add that I also am unable to get the official examples working. I placed the round_tracks
folder into the appropriate KiCad folder:
Then the same error that I encountered happened, because the identifier was wrong for a manually installed addon. Once I changed the identifier from com.gitlab.kicad.kicad-python.round_tracks
to round_tracks
the issue was fixed. However, same as with my personal plugin, nothing showed up in KiCad.