Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TheJigsApp/kicad-parts-placer-pcm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.10
Choose a base ref
...
head repository: TheJigsApp/kicad-parts-placer-pcm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 3 commits
  • 7 files changed
  • 1 contributor

Commits on Sep 14, 2024

  1. improving about text

    snhobbs committed Sep 14, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    agzam Ag Ibragimov
    Copy the full SHA
    bf50edc View commit details

Commits on Sep 15, 2024

  1. Copy the full SHA
    0f81a82 View commit details
  2. repackaging

    snhobbs committed Sep 15, 2024
    Copy the full SHA
    c3b439c View commit details
Showing with 89 additions and 77 deletions.
  1. +1 −1 libs/kicad-addon-metadata
  2. +15 −8 pcm/build.py
  3. +1 −4 src/__init__.py
  4. +1 −1 src/_version.py
  5. +0 −1 src/file_io_.py
  6. +0 −1 src/icon.png
  7. +71 −61 src/plugin.py
2 changes: 1 addition & 1 deletion libs/kicad-addon-metadata
Submodule kicad-addon-metadata updated from 4e8f41 to 6df9b5
23 changes: 15 additions & 8 deletions pcm/build.py
Original file line number Diff line number Diff line change
@@ -4,14 +4,20 @@
import json
import re

src_path = (Path(__file__).parent.parent / "src").absolute()
version_path = src_path / "_version.py"
download_url = "https://github.com/TheJigsApp/kicad-parts-placer-pcm/releases/download/"

metadata_template = Path(__file__).parent / "metadata_template.json"
build_path = Path("build").absolute()

def make_release_dir(version):
return f"v{version}/kicad-parts-placer-{version}-pcm"


src_path = (Path(__file__).parent.parent / "src").absolute()
version_path = src_path / "_version.py"
icons_path = src_path.parent / "icons"
resources_path = icons_path
metadata_template = Path(__file__).parent / "metadata_template.json"

build_path = Path("build").absolute()

# Delete build and recreate
try:
@@ -26,6 +32,9 @@
shutil.copy(
icons_path / "icon-64x64.png", build_path / "plugin" / "resources" / "icon.png"
)
shutil.copy(
icons_path / "icon-24x24.png", build_path / "plugin" / "plugins" / "icon-24x24.png"
)

# Clean out any __pycache__ or .pyc files (https://stackoverflow.com/a/41386937)
[p.unlink() for p in build_path.rglob("*.py[co]")]
@@ -57,9 +66,7 @@
md["versions"][0].update(
{
"version": verstr,
"download_url": "https://github.com/TheJigsApp/kicad-parts-placer-pcm/releases/download/v{0}/kicad-parts-placer-{0}-pcm.zip".format(
verstr
),
"download_url": download_url + make_release_dir(verstr) + ".zip",
}
)

@@ -68,7 +75,7 @@
json.dump(md, of, indent=2)

# Zip all files
pcm_name = "kicad-parts-placer-{0}-pcm".format(md["versions"][0]["version"])
pcm_name = make_release_dir(verstr)
pcm_path = build_path / pcm_name
zip_file = shutil.make_archive(pcm_path, "zip", build_path / "plugin")

5 changes: 1 addition & 4 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
import threading
import time
from pathlib import Path

import wx
import wx.aui
@@ -11,8 +10,6 @@
plugin = Plugin()
plugin.register()

icon_ = Path(__file__) / "icon-24x24.png"


def check_for_button():
# From Miles McCoo's blog
@@ -29,7 +26,7 @@ def callback(_):

while not wx.GetApp():
time.sleep(1)
bm = wx.Bitmap(icon_.as_posix(), wx.BITMAP_TYPE_PNG)
bm = wx.Bitmap(Meta.icon_file_path.as_posix(), wx.BITMAP_TYPE_PNG)
button_wx_item_id = 0

from pcbnew import ID_H_TOOLBAR
2 changes: 1 addition & 1 deletion src/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.10"
__version__ = "0.1.11"
1 change: 0 additions & 1 deletion src/file_io_.py

This file was deleted.

1 change: 0 additions & 1 deletion src/icon.png

This file was deleted.

132 changes: 71 additions & 61 deletions src/plugin.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import wx.aui
from wx.lib import buttons
import pcbnew
import dataclasses

path_ = Path(__file__).parent.absolute()
sys.path.append(str(path_))
@@ -60,24 +61,28 @@ def __init__(self):
self.group = False


@dataclasses.dataclass
class Meta:
"""
Information about package
"""

toolname = "kicadpartsplacer"
title = "Parts Placer"
body = (
toolname: str = "kicadpartsplacer"
title: str = "Parts Placer"
body: str = (
"Flip, mirror, move, rotate, and move components based off inputs from a spreadsheet. \
Enforce a form-factor, keep mechanical placements under version control, and allow \
updating of a templated design. Easily enforce grids or maintain test point patterns."
)
about_text = "Declaratively place components using a spreadsheet"
frame_title = "Parts Placer"
short_description = "Parts Placer"
website = "https://www.thejigsapp.com"
gitlink = "https://github.com/snhobbs/kicad-parts-placer-pcm"
version = _version.__version__
about_text: str = "Declaratively place components using a spreadsheet"
short_description: str = "Parts Placer"
frame_title: str = "Parts Placer"
website: str = "https://www.thejigsapp.com"
gitlink: str = "https://github.com/snhobbs/kicad-parts-placer-pcm"
version: str = _version.__version__
category: str = "Write PCB"
icon_dir: Path = Path(__file__).parent
icon_file_path: Path = icon_dir / "icon-24x24.png"


def setattr_keywords(obj, name, value):
@@ -90,7 +95,7 @@ class MyPanel(wx.Panel):
"""

def __init__(self, parent):
_log.info("MyPanel.__init__")
_log.debug("MyPanel.__init__")
super().__init__(parent)
self.settings = Settings()

@@ -130,8 +135,8 @@ def __init__(self, parent):
# Buttons
self.submit_button = buttons.GenButton(self, label="Submit")
self.cancel_button = buttons.GenButton(self, label="Cancel")
self.submit_button.SetBackgroundColour(wx.Colour(150, 225, 150))
self.cancel_button.SetBackgroundColour(wx.Colour(225, 150, 150))
self.submit_button.SetBackgroundColour(wx.Colour(100, 225, 100))
self.cancel_button.SetBackgroundColour(wx.Colour(225, 100, 100))
self.submit_button.Bind(wx.EVT_BUTTON, self.on_submit)
self.cancel_button.Bind(wx.EVT_BUTTON, self.on_cancel)

@@ -227,7 +232,7 @@ def on_submit(self, _):

valid, errors = kicad_parts_placer_.check_input_valid(components_df)
if len(errors):
msg = f"{'\n'.join(errors)}\n{', '.join(components_df.columns)}"
msg = "%s\n%s" % ("\n".join(errors), ", ".join(components_df.columns))
wx.MessageBox(
msg,
"Error",
@@ -237,7 +242,7 @@ def on_submit(self, _):

missing_refs = kicad_parts_placer_.get_missing_references(board, components_df)
if len(missing_refs):
msg = f"References not found on board: {', '.join(missing_refs)}"
msg = "References not found on board: %s" % (", ".join(missing_refs))
wx.MessageBox(
msg,
"Error",
@@ -285,14 +290,30 @@ def __init__(self, parent):
10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD
)

sizer = wx.BoxSizer(wx.VERTICAL)

# Static text for about information
message_text = wx.StaticText(self, label=Meta.about_text)
version_text = wx.StaticText(self, label=f"Version: {Meta.version}")
version_text.SetFont(bold)
sizer.Add(version_text, 1, wx.EXPAND | wx.ALL, 5)

message_text = wx.StaticText(self, label=Meta.about_text)
message_text.SetFont(font)
sizer.Add(message_text, 1, wx.EXPAND | wx.ALL, 5)

body_text = wx.StaticText(self, label=Meta.body)
body_text.SetFont(font)
sizer.Add(body_text, 5, wx.EXPAND | wx.ALL, 5)

input_header_text = wx.StaticText(self, label="Input Format:")
input_header_text.SetFont(bold)
sizer.Add(input_header_text, 1, wx.EXPAND | wx.ALL, 5)

input_header_body_text = wx.StaticText(
self, label="Note: White space and character case ignored"
)
input_header_body_text.SetFont(font)
sizer.Add(input_header_body_text, 1, wx.EXPAND | wx.ALL, 5)

list_ctrl = wx.ListCtrl(self, style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES)
list_ctrl.InsertColumn(0, "Field", width=150)
@@ -305,42 +326,35 @@ def __init__(self, parent):
list_ctrl.SetItem(
index, 2, str(key in kicad_parts_placer_._required_columns)
)
sizer.Add(list_ctrl, 1, wx.EXPAND | wx.ALL, 5)

from wx.lib.agw.hyperlink import HyperLinkCtrl

pre_link_text = wx.StaticText(self, label="Brought to you by: ")
link = HyperLinkCtrl(self, wx.ID_ANY, f"{Meta.website}", URL=Meta.website)
link.SetColours(wx.BLUE, wx.BLUE, wx.BLUE)

pre_gh_link_text = wx.StaticText(self, label="Git Repo: ")
gh_link = HyperLinkCtrl(self, wx.ID_ANY, f"{Meta.gitlink}", URL=Meta.gitlink)
gh_link.SetColours(wx.BLUE, wx.BLUE, wx.BLUE)

version_text.SetFont(bold)
body_text.SetFont(font)
message_text.SetFont(font)
input_header_text.SetFont(bold)
link_sizer = wx.BoxSizer(wx.HORIZONTAL)

pre_link_text = wx.StaticText(self, label="Brought to you by TheJigsApp: ")
pre_link_text.SetFont(font)

sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(version_text, 1, wx.EXPAND | wx.ALL, 5)
sizer.Add(message_text, 1, wx.EXPAND | wx.ALL, 5)
sizer.Add(body_text, 2, wx.EXPAND | wx.ALL, 5)
sizer.Add(input_header_text, 1, wx.EXPAND | wx.ALL, 5)
sizer.Add(input_header_body_text, 1, wx.EXPAND | wx.ALL, 5)
sizer.Add(list_ctrl, 1, wx.EXPAND, 5)

link_sizer = wx.BoxSizer(wx.HORIZONTAL)
link_sizer.Add(pre_link_text, 0, wx.EXPAND, 0)

link = HyperLinkCtrl(self, wx.ID_ANY, f"{Meta.website}", URL=Meta.website)
link.SetFont(font)
link.SetColours(wx.BLUE, wx.BLUE, wx.BLUE)
link_sizer.Add(link, 0, wx.EXPAND, 0)

sizer.Add(link_sizer, 1, wx.EXPAND | wx.ALL, 5)

gh_link_sizer = wx.BoxSizer(wx.HORIZONTAL)
gh_link_sizer.Add(pre_gh_link_text, 0, wx.EXPAND, 0)

gh_pre_link_text = wx.StaticText(self, label="Git Repo: ")
gh_pre_link_text.SetFont(font)
gh_link_sizer.Add(gh_pre_link_text, 0, wx.EXPAND, 0)

gh_link = HyperLinkCtrl(self, wx.ID_ANY, f"{Meta.gitlink}", URL=Meta.gitlink)
gh_link.SetFont(font)
gh_link.SetColours(wx.BLUE, wx.BLUE, wx.BLUE)
gh_link_sizer.Add(gh_link, 0, wx.EXPAND, 0)
sizer.Add(gh_link_sizer, 1, wx.EXPAND | wx.ALL, 5)

sizer.Add(gh_link_sizer, 1, wx.EXPAND | wx.ALL, 5)
self.SetSizer(sizer)


@@ -354,17 +368,17 @@ def __init__(self, parent, title):
parent, title=title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
)

# Sizer for layout
sizer = wx.BoxSizer(wx.HORIZONTAL)

# Create a notebook with two tabs
notebook = wx.Notebook(self)
tab_panel = MyPanel(notebook)
about_panel = AboutPanel(notebook)
# self.success_panel = SuccessPanel(notebook)

notebook.AddPage(tab_panel, "Main")
notebook.AddPage(about_panel, "About")

# Sizer for layout
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(notebook, 1, wx.EXPAND | wx.ALL, 10)

self.SetSizer(sizer)
@@ -375,10 +389,6 @@ def on_close(self, event):
self.EndModal(wx.ID_CANCEL)
event.Skip()

# def ShowSuccessPanel(self):
# self.GetSizer().GetChildren()[0].GetWindow().Destroy()
# self.GetSizer().Insert(0, self.success_panel)

def on_maximize(self, _):
self.fit_to_screen()

@@ -391,6 +401,16 @@ def fit_to_screen(self):
self.SetSize(wx.Size(screen_width, screen_height))


def get_gui_frame(name: str = "PcbFrame"):
pcb_frame = None

try:
pcb_frame = [x for x in wx.GetTopLevelWindows() if x.GetName() == name][0]
except IndexError:
pass
return pcb_frame


class Plugin(pcbnew.ActionPlugin):
def __init__(self):
super().__init__()
@@ -401,29 +421,19 @@ def __init__(self):
self.config_file = None

self.name = Meta.title
self.category = "Write PCB"
self.category = Meta.category
self.pcbnew_icon_support = hasattr(self, "show_toolbar_button")
self.show_toolbar_button = True
icon_dir = Path(__file__).parent
self.icon_file_path = icon_dir / "icon.png"
assert self.icon_file_path.exists()
self.icon_file_name = str(self.icon_file_path)
self.description = Meta.body

# assert icon_file_path.exists()
self.icon_file_name = str(Meta.icon_file_path)

def defaults(self):
pass

def Run(self):
pcb_frame = None

try:
pcb_frame = [
x for x in wx.GetTopLevelWindows() if x.GetName() == "PcbFrame"
][0]
except IndexError:
pass

dlg = MyDialog(pcb_frame, title=Meta.title)
dlg = MyDialog(get_gui_frame(name="PcbFrame"), title=Meta.title)
try:
dlg.ShowModal()