From 4cf82d3c3e141f6f8a231e67528552e4581d10b6 Mon Sep 17 00:00:00 2001 From: Dave Vandenbout Date: Fri, 20 Sep 2019 11:26:52 -0400 Subject: [PATCH] Enhance titles on part and footprint panels in part search GUI. * Modify setup to install part search GUI. --- setup.py | 5 +++- skidl/part_query.py | 2 +- skidl/search_gui/__init__.py | 0 {scripts => skidl/search_gui}/common.py | 21 ++++++++++---- .../search_gui}/footprint_painter.py | 0 .../search_gui}/skidl_footprint_search.py | 10 +++---- .../skidl_part_footprint_search.py | 28 ++++++++++++------- .../search_gui}/skidl_part_search.py | 16 ++++++++--- 8 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 skidl/search_gui/__init__.py rename {scripts => skidl/search_gui}/common.py (95%) rename {scripts => skidl/search_gui}/footprint_painter.py (100%) rename {scripts => skidl/search_gui}/skidl_footprint_search.py (99%) rename {scripts => skidl/search_gui}/skidl_part_footprint_search.py (91%) rename {scripts => skidl/search_gui}/skidl_part_search.py (98%) diff --git a/setup.py b/setup.py index c498aee4..6a457731 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,10 @@ "console_scripts": [ "netlist_to_skidl = skidl.netlist_to_skidl_main:main", "skidl_part_search = skidl.skidl_part_search:main", - ] + ], + "gui_scripts": [ + "SKiDL_Part_FP_Search = skidl.search_gui.skidl_part_footprint_search:main" + ], }, package_dir={"skidl": "skidl"}, include_package_data=True, diff --git a/skidl/part_query.py b/skidl/part_query.py index 78d45e89..1dca524b 100644 --- a/skidl/part_query.py +++ b/skidl/part_query.py @@ -178,7 +178,7 @@ class FootprintCache(dict): def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) - self.reset() # Cache starts off empty, hence invalid. + self.reset() # Cache starts off empty, hence invalid. def reset(self): self.clear() # Clear out cache. diff --git a/skidl/search_gui/__init__.py b/skidl/search_gui/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/common.py b/skidl/search_gui/common.py similarity index 95% rename from scripts/common.py rename to skidl/search_gui/common.py index 27863364..100c49f0 100644 --- a/scripts/common.py +++ b/skidl/search_gui/common.py @@ -40,6 +40,8 @@ SPACING = 5 TEXT_BOX_WIDTH = 200 CELL_BCK_COLOUR = wx.Colour(255, 255, 255) # Table cell background color. +TITLE_BCK_COLOUR = wx.Colour(128, 128, 128) +TITLE_FG_COLOUR = wx.Colour(200, 200, 200) # IDs for part and footprint panels. @@ -71,7 +73,12 @@ def add_title(window, title_text, location): titled_window = wx.Panel(window.GetParent()) window.Reparent(titled_window) - title = wx.StaticText(titled_window, label=title_text) + title = wx.StaticText( + titled_window, label=title_text, style=wx.ALIGN_CENTRE_HORIZONTAL + ) + title.SetBackgroundColour(TITLE_BCK_COLOUR) + title.SetForegroundColour(TITLE_FG_COLOUR) + title.SetFont(title.GetFont().MakeLarger().MakeBold().MakeItalic()) box = wx.BoxSizer(wx.VERTICAL) if location == wx.TOP: @@ -305,7 +312,7 @@ def Resize(self, numRows=0): self.DeleteRows(0, -num_rows_chg, True) elif num_rows_chg > 0: self.AppendRows(num_rows_chg) - self.SetSortingIndicator(0, 0) # No sorting at the start. + self.SetSortingIndicator(0, 0) # No sorting at the start. self.ColourGridBackground() # Create a list of row indices that will be sorted along with the @@ -416,9 +423,11 @@ def OnCopy(self, event): for selcol in self.GetSelectedCols(): for r in range(num_rows): cells.append((r, selcol)) - for topleft, bottomright in zip(self.GetSelectionBlockTopLeft(), self.GetSelectionBlockBottomRight()): - for r in range(topleft[0], bottomright[0]+1): - for c in range(topleft[1], bottomright[1]+1): + for topleft, bottomright in zip( + self.GetSelectionBlockTopLeft(), self.GetSelectionBlockBottomRight() + ): + for r in range(topleft[0], bottomright[0] + 1): + for c in range(topleft[1], bottomright[1] + 1): cells.append((r, c)) cells.sort() @@ -428,7 +437,7 @@ def OnCopy(self, event): for row, col in cells: if row != prev_row: vals += "\n" - vals += '"' + str(self.GetCellValue(row, col)) + '"' + ', ' + vals += '"' + str(self.GetCellValue(row, col)) + '"' + ", " prev_row = row # Make a data object to hold the cell values. diff --git a/scripts/footprint_painter.py b/skidl/search_gui/footprint_painter.py similarity index 100% rename from scripts/footprint_painter.py rename to skidl/search_gui/footprint_painter.py diff --git a/scripts/skidl_footprint_search.py b/skidl/search_gui/skidl_footprint_search.py similarity index 99% rename from scripts/skidl_footprint_search.py rename to skidl/search_gui/skidl_footprint_search.py index 8f141b00..47a00d5f 100644 --- a/scripts/skidl_footprint_search.py +++ b/skidl/search_gui/skidl_footprint_search.py @@ -34,16 +34,16 @@ import pykicad.module as pym import wx -from common import * -from footprint_painter import FootprintPainter from skidl import ( KICAD, footprint_search_paths, + natural_sort_key, rmv_quotes, search_footprints_iter, skidl_cfg, - natural_sort_key, ) +from skidl.search_gui.common import * +from skidl.search_gui.footprint_painter import FootprintPainter APP_TITLE = "SKiDL Footprint Search" @@ -430,9 +430,9 @@ def clear_fp_panel(): # Clear the footprint panel desc, link, and painting. self.fp_desc.SetDescription("") self.datasheet_link.SetURL(None) - #self.painting_title_panel.Hide() + # self.painting_title_panel.Hide() self.fp_painting_panel.footprint = None - #self.fp_painting_panel.Hide() + # self.fp_painting_panel.Hide() self.fp_panel.Layout() # Get the selected row in the lib/footprint table and translate it to the row in the data table. diff --git a/scripts/skidl_part_footprint_search.py b/skidl/search_gui/skidl_part_footprint_search.py similarity index 91% rename from scripts/skidl_part_footprint_search.py rename to skidl/search_gui/skidl_part_footprint_search.py index d4310fbc..d8f6c311 100644 --- a/scripts/skidl_part_footprint_search.py +++ b/skidl/search_gui/skidl_part_footprint_search.py @@ -32,10 +32,17 @@ import wx -from common import * -from skidl import KICAD, footprint_search_paths, footprint_cache, lib_search_paths, SchLib, skidl_cfg -from skidl_footprint_search import FootprintSearchPanel -from skidl_part_search import PartSearchPanel +from skidl import ( + KICAD, + SchLib, + footprint_cache, + footprint_search_paths, + lib_search_paths, + skidl_cfg, +) +from skidl.search_gui.common import * +from skidl.search_gui.skidl_footprint_search import FootprintSearchPanel +from skidl.search_gui.skidl_part_search import PartSearchPanel APP_TITLE = "SKiDL Part/Footprint Search" APP_EXIT = 1 @@ -94,9 +101,7 @@ def InitMenus(self): srchMenu.Append(footprintSrchPathItem) self.Bind(wx.EVT_MENU, self.OnFootprintSearchPath, id=FOOTPRINT_SEARCH_PATH) - refreshItem = wx.MenuItem( - srchMenu, REFRESH, "Refresh part + footprint paths" - ) + refreshItem = wx.MenuItem(srchMenu, REFRESH, "Refresh part + footprint paths") srchMenu.Append(refreshItem) self.Bind(wx.EVT_MENU, self.OnRefresh, id=REFRESH) @@ -155,7 +160,6 @@ def OnRefresh(self, event): SchLib.reset() footprint_cache.reset() - def ShowHelp(self, e): Feedback( """ @@ -202,11 +206,15 @@ def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) # Subpanel for part search panel. - self.part_panel = add_border(add_title(PartSearchPanel(self), "Part Search", wx.TOP), wx.BOTTOM) + self.part_panel = add_border( + add_title(PartSearchPanel(self), "Part Search", wx.TOP), wx.BOTTOM + ) # self.part_panel = box_it(PartSearchPanel(self), "Part Search") # Subpanel for footprint search. - self.footprint_panel = add_border(add_title(FootprintSearchPanel(self), "Footprint Search", wx.TOP), wx.TOP) + self.footprint_panel = add_border( + add_title(FootprintSearchPanel(self), "Footprint Search", wx.TOP), wx.TOP + ) # self.footprint_panel = box_it(FootprintSearchPanel(self), "Footprint Search") # Split subpanels top/bottom. diff --git a/scripts/skidl_part_search.py b/skidl/search_gui/skidl_part_search.py similarity index 98% rename from scripts/skidl_part_search.py rename to skidl/search_gui/skidl_part_search.py index d1348f69..07aade94 100644 --- a/scripts/skidl_part_search.py +++ b/skidl/search_gui/skidl_part_search.py @@ -33,8 +33,14 @@ import wx -from common import * -from skidl import KICAD, lib_search_paths, search_parts_iter, skidl_cfg, natural_sort_key +from skidl import ( + KICAD, + lib_search_paths, + natural_sort_key, + search_parts_iter, + skidl_cfg, +) +from skidl.search_gui.common import * APP_TITLE = "SKiDL Part Search" @@ -236,7 +242,7 @@ def InitSearchPanel(self, parent): # Button to copy selected lib/part to clipboard. copy_btn = wx.Button(search_panel, label="Copy", size=BTN_SIZE) copy_btn.Bind(wx.EVT_BUTTON, self.OnCopy) - tip = wx.ToolTip("Copy the selected library and part to the clipboard.") + tip = wx.ToolTip("Copy the selected part to the clipboard.") copy_btn.SetToolTip(tip) # Grid for arranging text box, grid and buttons. @@ -281,7 +287,9 @@ def InitPartPanel(self, parent): flag=wx.ALL, border=SPACING, ) - self.pin_info = MyGrid(part_panel, ("Pin", "Name", "Type", "Unit"), CELL_BCK_COLOUR) + self.pin_info = MyGrid( + part_panel, ("Pin", "Name", "Type", "Unit"), CELL_BCK_COLOUR + ) self.pin_info.SetSelectionMode(wx.grid.Grid.GridSelectionModes.SelectCells) self.pin_info.Resize(10) self.pin_info.SetSortFunc(0, natural_sort_key) # Natural sort pin numbers.