Skip to content

Commit

Permalink
Add buttons to easy add Ω and µ to the search string. Fix for #66
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouni committed Jul 30, 2024
1 parent 98f678f commit 5f8bbcc
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions partselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ def __init__(self, parent, parts):
)
self.keyword.SetHint("e.g. 10k 0603")

self.ohm_button = wx.Button(
self,
wx.ID_ANY,
"Ω",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(20, -1)),
0,
)
self.ohm_button.SetToolTip("Append the Ω symbol to the search string")

self.micro_button = wx.Button(
self,
wx.ID_ANY,
"µ",
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(20, -1)),
0,
)
self.micro_button.SetToolTip("Append the µ symbol to the search string")

manufacturer_label = wx.StaticText(
self,
wx.ID_ANY,
Expand Down Expand Up @@ -239,6 +259,18 @@ def __init__(self, parent, parts):
wx.LEFT | wx.RIGHT | wx.BOTTOM,
5,
)
keyword_search_row1.Add(
self.ohm_button,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM,
5,
)
keyword_search_row1.Add(
self.micro_button,
0,
wx.LEFT | wx.RIGHT | wx.BOTTOM,
5,
)

search_sizer_one = wx.BoxSizer(wx.VERTICAL)
search_sizer_one.Add(manufacturer_label, 0, wx.ALL, 5)
Expand Down Expand Up @@ -342,6 +374,8 @@ def __init__(self, parent, parts):
search_sizer.Add(search_sizer_row2)

self.keyword.Bind(wx.EVT_TEXT, self.search_dwell)
self.ohm_button.Bind(wx.EVT_BUTTON, self.add_ohm_symbol)
self.micro_button.Bind(wx.EVT_BUTTON, self.add_micro_symbol)
self.manufacturer.Bind(wx.EVT_TEXT, self.search_dwell)
self.package.Bind(wx.EVT_TEXT, self.search_dwell)
self.category.Bind(wx.EVT_COMBOBOX, self.update_subcategories)
Expand Down Expand Up @@ -561,6 +595,14 @@ def enable_toolbar_buttons(self, state):
]:
b.Enable(bool(state))

def add_ohm_symbol(self, *_):
"""Append the Ω symbol to the search string."""
self.keyword.AppendText("Ω")

def add_micro_symbol(self, *_):
"""Append the µ symbol to the search string."""
self.keyword.AppendText("µ")

def search_dwell(self, *_):
"""Initiate a search once the timeout expires.
Expand Down

0 comments on commit 5f8bbcc

Please sign in to comment.