Skip to content

Commit

Permalink
Enhance titles on part and footprint panels in part search GUI.
Browse files Browse the repository at this point in the history
* Modify setup to install part search GUI.
  • Loading branch information
Dave Vandenbout committed Sep 20, 2019
1 parent ca946c5 commit 4cf82d3
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 27 deletions.
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion skidl/part_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Empty file added skidl/search_gui/__init__.py
Empty file.
21 changes: 15 additions & 6 deletions scripts/common.py → skidl/search_gui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -155,7 +160,6 @@ def OnRefresh(self, event):
SchLib.reset()
footprint_cache.reset()


def ShowHelp(self, e):
Feedback(
"""
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4cf82d3

Please sign in to comment.