Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buttons to easy add Ω and µ to the search string. Fix for #66 #508

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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