Skip to content

Commit

Permalink
adding working version
Browse files Browse the repository at this point in the history
  • Loading branch information
snhobbs committed Jun 2, 2024
1 parent c885607 commit 070723e
Show file tree
Hide file tree
Showing 30 changed files with 4,208 additions and 330 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build_asset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Asset
on:
workflow_dispatch:
branches:

jobs:
build:

name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@master

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Update zip
run: |
cd pcm
python build.py
cd build
echo "ZIP_NAME=$(ls kicadtestpoints*.zip)" >> $GITHUB_ENV
echo "PCM_NAME=$(ls kicadtestpoints*.zip | rev | cut -c 5- | rev)" >> $GITHUB_ENV
- name: Upload pcm build to action - avoid double-zip
uses: actions/upload-artifact@v3
with:
name: ${{ env.PCM_NAME }}
path: ./pcm/build/${{ env.PCM_NAME }}
retention-days: 7
33 changes: 33 additions & 0 deletions .github/workflows/build_asset_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Asset for Release
on:
release:
types: [published]

jobs:
build:

name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@master

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Update zip
run: |
cd pcm
python build.py
cd build
echo "ZIP_NAME=$(ls kicadtestpoints*.zip)" >> $GITHUB_ENV
echo "PCM_NAME=$(ls kicadtestpoints*.zip | rev | cut -c 5- | rev)" >> $GITHUB_ENV
- name: Publish release
uses: softprops/action-gh-release@v1
with:
files: |
./pcm/build/${{ env.ZIP_NAME }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
libs
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Aknowlegements
+ KiCAD PCM Packaging: Fully based off of (https://github.com/sparkfun/SparkFun_KiCad_Panelizer).
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .SparkFunKiCadPanelizer import plugin
Binary file added icons/SparkFunPanelizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/install_from_file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/panelizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/run_panelizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/run_panelizer_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions kicadtestpoints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import sys
import subprocess
import threading
import time

import wx
import wx.aui
from wx import FileConfig

import os
from .util import add_paths
dir_path = os.path.dirname(os.path.realpath(__file__))
paths = dir_path
#paths = [
# os.path.join(dir_path, 'deps'),
#]

def check_for_panelizer_button():
# From Miles McCoo's blog
# https://kicad.mmccoo.com/2017/03/05/adding-your-own-command-buttons-to-the-pcbnew-gui/
def find_pcbnew_window():
windows = wx.GetTopLevelWindows()
pcbneww = [w for w in windows if "pcbnew" in w.GetTitle().lower()]
if len(pcbneww) != 1:
return None
return pcbneww[0]

def callback(_):
plugin.Run()

while not wx.GetApp():
time.sleep(1)
bm = wx.Bitmap(os.path.join(os.path.dirname(__file__),'icon.png'), wx.BITMAP_TYPE_PNG)
button_wx_item_id = 0

from pcbnew import ID_H_TOOLBAR
while True:
time.sleep(1)
pcbnew_window = find_pcbnew_window()
if not pcbnew_window:
continue

top_tb = pcbnew_window.FindWindowById(ID_H_TOOLBAR)
if button_wx_item_id == 0 or not top_tb.FindTool(button_wx_item_id):
top_tb.AddSeparator()
button_wx_item_id = wx.NewId()
top_tb.AddTool(button_wx_item_id, "SparkFunKiCadPanelizer", bm,
"SparkFun KiCad Panelizer", wx.ITEM_NORMAL)
top_tb.Bind(wx.EVT_TOOL, callback, id=button_wx_item_id)
top_tb.Realize()


try:
with add_paths(paths):
from .plugin import PanelizerPlugin
plugin = PanelizerPlugin()
plugin.register()
except Exception as e:
print(e)
import logging
root = logging.getLogger()
root.debug(repr(e))

# Add a button the hacky way if plugin button is not supported
# in pcbnew, unless this is linux.
if not plugin.pcbnew_icon_support and not sys.platform.startswith('linux'):
t = threading.Thread(target=check_for_panelizer_button)
t.daemon = True
t.start()

1 change: 1 addition & 0 deletions kicadtestpoints/dialog/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .dialog import Dialog
18 changes: 18 additions & 0 deletions kicadtestpoints/dialog/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

import wx

class DialogShim(wx.Dialog):
def __init__(self, parent, **kwargs):
try:
wx.StockGDI._initStockObjects()
except:
pass

wx.Dialog.__init__(self, parent, **kwargs)

def SetSizeHints(self, a, b, c=None):
if c is not None:
super(wx.Dialog, self).SetSizeHints(a,b,c)
else:
super(wx.Dialog, self).SetSizeHints(a,b) # Was super(wx.Dialog, self).SetSizeHintsSz(a,b)

Loading

0 comments on commit 070723e

Please sign in to comment.