Properly update tree when windows added or removed

In CustromTreeCtrl and HyperTreeList when a window is added or deleted
from an item the row height can change causing the entire tree to
change shape. This sets the _dirty flag so the tree gets recalcualted
during the next Idle handler.
In HyperTreeList deleting an item didn't properly remove it from the
_itemWithWindow list.
This commit is contained in:
cbeytas
2018-11-21 14:45:03 -05:00
parent e11848f735
commit 7a8789347e
2 changed files with 8 additions and 2 deletions

View File

@@ -4375,6 +4375,7 @@ class CustomTreeCtrl(wx.ScrolledWindow):
item.DeleteWindow()
if item in self._itemWithWindow:
self._itemWithWindow.remove(item)
self._dirty = True
def GetItemWindowEnabled(self, item):

View File

@@ -1726,9 +1726,12 @@ class TreeListItem(GenericTreeItem):
if column >= len(self._wnd):
return
if self._wnd[column]:
self._wnd[column].Destroy()
wnd = self._wnd[column]
if wnd:
wnd.Destroy()
self._wnd[column] = None
if not any(self._wnd) and self in self._owner._itemWithWindow:
self._owner._itemWithWindow.remove(self)
def GetWindowEnabled(self, column=None):
@@ -2270,6 +2273,8 @@ class TreeListMainWindow(CustomTreeCtrl):
if window:
self._hasWindows = True
# Recalculate tree during idle time.
self._dirty = True
def SetItemWindowEnabled(self, item, enable=True, column=None):
"""