From 4c1d7a729454158c579bc79b7fc11bb307f8aeba Mon Sep 17 00:00:00 2001 From: bouni Date: Tue, 30 Jul 2024 14:00:10 +0200 Subject: [PATCH] =?UTF-8?q?Add=20buttons=20to=20easy=20add=20=20=CE=A9=20a?= =?UTF-8?q?nd=20=C2=B5=20to=20the=20search=20string.=20Fix=20for=20#66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- partselector.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/partselector.py b/partselector.py index ab0fad2..6ae3cfb 100644 --- a/partselector.py +++ b/partselector.py @@ -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, @@ -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) @@ -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) @@ -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.