Skip to content

Commit

Permalink
Parameter Category Search
Browse files Browse the repository at this point in the history
Added dropdown for categorical search if parameters
  • Loading branch information
Akshath-Singhal committed Aug 23, 2019
1 parent 91b9b5a commit 2ab3289
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions MAVProxy/modules/mavproxy_paramedit/param_editor_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, *args, **kwds):
self.fetch_params = wx.Button(self, wx.ID_ANY, ("Fetch all"))
self.write_params = wx.Button(self, wx.ID_ANY, ("Write"))
self.search_key = wx.TextCtrl(self, wx.ID_ANY, "")
self.search_list = wx.Choice(self, wx.ID_ANY, choices=['Flight Modes','COMPASS','INS','BATTERY'])
self.display_list = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1))
self.search_key.SetHint("Search")
self.__set_properties()
Expand All @@ -56,6 +57,7 @@ def __init__(self, *args, **kwds):
self.Bind(wx.EVT_BUTTON, self.fetch_param, self.fetch_params)
self.Bind(wx.EVT_BUTTON, self.write_param, self.write_params)
self.Bind(wx.EVT_TEXT, self.key_change, self.search_key)
self.Bind(wx.EVT_CHOICE, self.category_change, self.search_list)
if float(str(wx.__version__).split('.')[0]) < 4.0:
self.Bind(wx.grid.EVT_GRID_CMD_CELL_CHANGE, self.ParamChanged,
self.display_list)
Expand Down Expand Up @@ -137,6 +139,8 @@ def __do_layout(self):
sizer_5.Add((10, 10), 0, 0, 0)
sizer_5.Add(self.search_key, 0, 0, 0)
sizer_5.Add((10, 10), 0, 0, 0)
sizer_5.Add(self.search_list, 0, 0, 0)
sizer_5.Add((10, 10), 0, 0, 0)
sizer_3.Add(sizer_5, 0, 0, 0)
sizer_2.Add(sizer_3, 0, 0, 0)
sizer_2.Add((10, 10), 0, 0, 0)
Expand Down Expand Up @@ -464,6 +468,26 @@ def key_change(self, event): # wxGlade: ParamEditor.<event_handler>
self.key_redraw()
event.Skip()

def category_change(self, event):
self.gui_event_queue_lock.acquire()
key = self.search_list.GetString(self.search_list.GetSelection())
if key == 'BATTERY':
key = 'BATT'
elif key == 'Flight Modes':
if self.vehicle_name == 'APMrover2':
key = 'MODE'
else:
key = 'FLTMODE'
else:
key = key + '_'
temp = {}
for param, value in self.param_received.items():
if key.lower() in param.lower():
temp[param] = value
self.redraw_grid(temp)
self.gui_event_queue_lock.release()
event.Skip()

def key_redraw(self):
self.gui_event_queue_lock.acquire()
key = self.search_key.GetValue()
Expand Down

0 comments on commit 2ab3289

Please sign in to comment.