Skip to content

Instantly share code, notes, and snippets.

@hyOzd
Created February 17, 2017 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyOzd/9a579db5077d0d1aec7c476b193da380 to your computer and use it in GitHub Desktop.
Save hyOzd/9a579db5077d0d1aec7c476b193da380 to your computer and use it in GitHub Desktop.
an experiment to add menu items to kicad pcbnew via scripting
import wx
def showMacros(e):
print("heey")
def findPcbnewWindow():
windows = wx.GetTopLevelWindows()
title = "Pcbnew"
pcbnew = filter(lambda w: w.GetTitle() == title, windows)
if len(pcbnew) != 1:
raise Exception("Cannot find pcbnew window from title matching!")
return pcbnew[0]
def run():
win = findPcbnewWindow()
menuBar = win.MenuBar
# add Macros menu item under Tools menu
toolsMenu = menuBar.GetMenu(menuBar.FindMenu("Tools"))
macrosMenuItem = toolsMenu.Append(wx.ID_ANY, "Macros")
win.Bind(wx.EVT_MENU, showMacros)
if __name__ == "__main__":
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment