Regression: when a user enters text into the filter field and no elements are found, wxPython returns 'invalid item' when attempting to obtain selection from the search tree. Thus coerce this to default element (initial element).
def filter(self, filterText, newElementType=False):\r
# If this is a new element type, use the element nearest the cursor.\r
# Otherwise, use the currently selected element.\r
- defaultElement = self._initialElement if newElementType else self.tree.GetItemData(self.tree.GetSelection())\r
+ # #8753: wxPython 4 returns "invalid tree item" when the tree view is empty, so use initial element if appropriate.\r
+ try:\r
+ defaultElement = self._initialElement if newElementType else self.tree.GetItemData(self.tree.GetSelection())\r
+ except:\r
+ defaultElement = self._initialElement\r
# Clear the tree.\r
self.tree.DeleteChildren(self.treeRoot)\r
\r