Skip to content

Commit

Permalink
Removed fixed size for Search and Copy buttons in zyc.
Browse files Browse the repository at this point in the history
* Put scrollbar on Description text box.
* Beautified code.
  • Loading branch information
Dave Vandenbout committed Oct 7, 2019
1 parent b28ae27 commit acaa17b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 32 deletions.
8 changes: 2 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@
# packages=['skidl',],
packages=setuptools.find_packages(exclude=["tests"]),
entry_points={
"console_scripts": [
"netlist_to_skidl = skidl.netlist_to_skidl_main:main",
],
"gui_scripts": [
"zyc = skidl.search_gui.skidl_part_footprint_search:main",
],
"console_scripts": ["netlist_to_skidl = skidl.netlist_to_skidl_main:main"],
"gui_scripts": ["zyc = skidl.search_gui.skidl_part_footprint_search:main"],
},
package_dir={"skidl": "skidl"},
include_package_data=True,
Expand Down
11 changes: 9 additions & 2 deletions skidl/part_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ def parse_search_terms(terms):
non-white chars to prevent the initial portion of a quoted string from being
gathered up as a non-white character sequence.
"""
return re.sub(r"((\".*?\")|(\S+))\s*", r"(?=.*(\1))", terms.strip().rstrip()).replace('"', "") + ".*"
return (
re.sub(r"((\".*?\")|(\S+))\s*", r"(?=.*(\1))", terms.strip().rstrip()).replace(
'"', ""
)
+ ".*"
)


def search_parts_iter(terms, tool=None):
Expand Down Expand Up @@ -333,7 +338,9 @@ def search_footprints_iter(terms, tool=None):
search_text = "\n".join([search_text, line])

# Search the string for a match with the search terms.
if fullmatch(terms, search_text, flags=re.IGNORECASE | re.MULTILINE | re.DOTALL):
if fullmatch(
terms, search_text, flags=re.IGNORECASE | re.MULTILINE | re.DOTALL
):
yield "MODULE", fp_lib, module_text, module_name

# At the end, all modules have been scanned and the footprint cache is valid.
Expand Down
7 changes: 1 addition & 6 deletions skidl/search_gui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
import wx.lib.newevent

MINIMUM_PANE_SIZE = 300
BTN_SIZE = (50, -1)
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)
Expand Down Expand Up @@ -170,10 +168,7 @@ def __init__(self, parent, label):
)

self.desc = wx.TextCtrl(
self,
# size=(TEXT_BOX_WIDTH, 60),
size=(10000, 60),
style=wx.TE_READONLY | wx.TE_MULTILINE | wx.TE_NO_VSCROLL,
self, size=(10000, 60), style=wx.TE_READONLY | wx.TE_MULTILINE
)
vbox.Add(self.desc, proportion=0, flag=wx.ALL, border=SPACING)

Expand Down
17 changes: 7 additions & 10 deletions skidl/search_gui/skidl_footprint_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,13 @@ def InitSearchPanel(self, parent):
search_panel.SetSizer(vbox)

# Text box for footprint search string.
self.search_text = wx.TextCtrl(
search_panel, size=(TEXT_BOX_WIDTH, -1), style=wx.TE_PROCESS_ENTER
)
self.search_text = wx.TextCtrl(search_panel, style=wx.TE_PROCESS_ENTER)
self.search_text.Bind(wx.EVT_TEXT_ENTER, self.OnSearch)
tip = wx.ToolTip("Enter text or regular expression to select footprints.")
self.search_text.SetToolTip(tip)

# Button to initiate search for footprints containing search string.
search_btn = wx.Button(search_panel, label="Search", size=BTN_SIZE)
search_btn = wx.Button(search_panel, label="Search")
search_btn.Bind(wx.EVT_BUTTON, self.OnSearch)
tip = wx.ToolTip(
"Search for footprints containing the text or regular expression."
Expand All @@ -295,7 +293,7 @@ def InitSearchPanel(self, parent):
self.found_footprints.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnCopy)

# Button to copy selected footprint to clipboard.
copy_btn = wx.Button(search_panel, label="Copy", size=BTN_SIZE)
copy_btn = wx.Button(search_panel, label="Copy")
copy_btn.Bind(wx.EVT_BUTTON, self.OnCopy)
tip = wx.ToolTip("Copy the selected footprint to the clipboard.")
copy_btn.SetToolTip(tip)
Expand Down Expand Up @@ -428,18 +426,17 @@ def OnSelectCell(self, event):

# Ths is a null footprint that just paints an "X" (cross) when there's no valid footprint.
null_module_text = [
"(module NULL",
"(fp_line (start 0.0 0.0) (end 1.0 1.0) (layer F.Fab) (width 0.01))",
"(fp_line (start 1.0 0.0) (end 0.0 1.0) (layer F.Fab) (width 0.01))",
")",
"(module NULL",
"(fp_line (start 0.0 0.0) (end 1.0 1.0) (layer F.Fab) (width 0.01))",
"(fp_line (start 1.0 0.0) (end 0.0 1.0) (layer F.Fab) (width 0.01))",
")",
]

# Get the selected row in the lib/footprint table and translate it to the row in the data table.
self.found_footprints.ClearSelection()
self.found_footprints.SelectRow(event.GetRow())
row = self.found_footprints.GetDataRowIndex(event.GetRow())


# Get the text describing the footprint structure.
try:
module_text = self.footprints[row][1]
Expand Down
14 changes: 7 additions & 7 deletions skidl/search_gui/skidl_part_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,13 @@ def InitSearchPanel(self, parent):
search_panel.SetSizer(vbox)

# Text box for part search string.
self.search_text = wx.TextCtrl(
search_panel, size=(TEXT_BOX_WIDTH, -1), style=wx.TE_PROCESS_ENTER
)
self.search_text = wx.TextCtrl(search_panel, style=wx.TE_PROCESS_ENTER)
self.search_text.Bind(wx.EVT_TEXT_ENTER, self.OnSearch)
tip = wx.ToolTip("Enter text or regular expression to select parts.")
self.search_text.SetToolTip(tip)

# Button to initiate search for parts containing search string.
search_btn = wx.Button(search_panel, label="Search", size=BTN_SIZE)
search_btn = wx.Button(search_panel, label="Search")
search_btn.Bind(wx.EVT_BUTTON, self.OnSearch)
tip = wx.ToolTip("Search for parts containing the text or regular expression.")
search_btn.SetToolTip(tip)
Expand All @@ -240,7 +238,7 @@ def InitSearchPanel(self, parent):
self.found_parts.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnCopy)

# Button to copy selected lib/part to clipboard.
copy_btn = wx.Button(search_panel, label="Copy", size=BTN_SIZE)
copy_btn = wx.Button(search_panel, label="Copy")
copy_btn.Bind(wx.EVT_BUTTON, self.OnCopy)
tip = wx.ToolTip("Copy the selected part to the clipboard.")
copy_btn.SetToolTip(tip)
Expand All @@ -260,7 +258,9 @@ def InitSearchPanel(self, parent):
[
search_btn,
(self.search_text, 1, wx.EXPAND),
stack_it(copy_btn, self.template_ckbx), # Copy & template buttons stacked together.
stack_it(
copy_btn, self.template_ckbx
), # Copy & template buttons stacked together.
(self.found_parts, 1, wx.EXPAND),
]
)
Expand Down Expand Up @@ -429,7 +429,7 @@ def OnSelectCell(self, event):
fp_srch_terms = re.sub("[*?]", ".\g<0>", fp_srch_terms)
# Use the number of pins in the part to refine the search.
num_pins = len(part.pins)
fp_srch_terms = " ".join((fp_srch_terms, '^#pads={}$'.format(num_pins)))
fp_srch_terms = " ".join((fp_srch_terms, "^#pads={}$".format(num_pins)))

# Send the string of search terms to the footprint search panel.
evt = SendSearchTermsEvent(search_terms=fp_srch_terms)
Expand Down
1 change: 1 addition & 0 deletions skidl/skidl.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def store(self, dir="."):
with open(path, "w") as cfg_fp:
json.dump(self, cfg_fp, indent=4)


def get_kicad_lib_tbl_dir():
"""Get the path to where the global fp-lib-table file is found."""

Expand Down
2 changes: 1 addition & 1 deletion skidl/tools/kicad.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _load_sch_lib_(self, filename=None, lib_search_paths_=None):
keywords="",
datasheet="",
description="",
search_text = "",
search_text="",
)
)

Expand Down

0 comments on commit acaa17b

Please sign in to comment.