Skip to content

Commit

Permalink
fixes, black
Browse files Browse the repository at this point in the history
  • Loading branch information
lindakladivova committed Jan 8, 2024
1 parent 0f7dedf commit 1e11417
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions gui/wxpython/history/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def __init__(
self.search = SearchCtrl(self)
self.search.SetDescriptiveText(_("Search"))
self.search.ShowCancelButton(True)
self.search.Bind(wx.EVT_TEXT, lambda evt: self.Filter(evt.GetString()))
self.search.Bind(wx.EVT_TEXT, lambda evt: self.tree.Filter(evt.GetString()))
self.search.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, lambda evt: self.tree.Filter(""))

# tree with layers
self.tree = HistoryBrowserTree(self, giface=giface)
self.tree.SetToolTip(_("Double-click to run selected tool"))
Expand All @@ -80,4 +80,4 @@ def _layout(self):

self.SetSizerAndFit(sizer)
self.SetAutoLayout(True)
self.Layout()
self.Layout()
17 changes: 7 additions & 10 deletions gui/wxpython/history/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
):
"""History Browser Tree constructor."""
self._model = TreeModel(ModuleNode)
self._orig_model = self._model
super().__init__(parent=parent, model=self._model, id=wx.ID_ANY, style=style)

self._giface = giface
Expand All @@ -90,13 +91,10 @@ def __init__(
self.itemActivated.connect(lambda node: self.Run(node))
self.contextMenu.connect(self.OnRightClick)

def _getModel(self):
"""Returns a deep copy of the tree model."""
return copy.deepcopy(self._model)

def _refreshTree(self):
"""Refresh tree model"""
self.SetModel(self._getModel())
"""Refresh tree models"""
self.SetModel(copy.deepcopy(self._model))
self._orig_model = self._model

def _getSelectedNode(self):
selection = self.GetSelected()
Expand Down Expand Up @@ -126,12 +124,11 @@ def Filter(self, text):
"""Filter history
:param str text: text string
"""
model = self._getModel()
if text:
model = model.Filtered(key=["command"], value=text)
self.SetModel(model)
self._model = self._orig_model.Filtered(key=["command"], value=text)
else:
self.SetModel(model)
self._model = self._orig_model
self.RefreshItems()

def UpdateHistoryModelFromScratch(self):
"""Fill tree history model based on the current history log from scratch."""
Expand Down

0 comments on commit 1e11417

Please sign in to comment.