From fd57321cb3cd994a7dcfdc90fd6ad5cdcfd46892 Mon Sep 17 00:00:00 2001 From: cbeytas Date: Mon, 7 Jan 2019 00:21:13 -0500 Subject: [PATCH] Add GetFocusedItem method to CustomTreeCtrl The GetSelection() method of CustomTreeCtrl and HyperTreeList have the same behavior as the GetFocusedItem() method of wx.TreeCtrl. The GetCurrentItem() method of HyperTreeList also does the exact same thing. Try to consolidate and document these methods. The CustomTreeCtrl "Basic Functionalites" section states that "All the methods available in TreeCtrl are also available in CustomTreeCtrl", this brings it one step closer to reality. --- wx/lib/agw/customtreectrl.py | 2 ++ wx/lib/agw/hypertreelist.py | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/wx/lib/agw/customtreectrl.py b/wx/lib/agw/customtreectrl.py index 943395bf..01660c3b 100644 --- a/wx/lib/agw/customtreectrl.py +++ b/wx/lib/agw/customtreectrl.py @@ -3123,6 +3123,8 @@ class CustomTreeCtrl(wx.ScrolledWindow): return self._current + GetFocusedItem = GetSelection + def ToggleItemSelection(self, item): """ diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 9fe9288d..263e3930 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -2620,9 +2620,12 @@ class TreeListMainWindow(CustomTreeCtrl): def GetCurrentItem(self): - """ Returns the current item. """ + """Returns the current item. - return self._current + This is the same as :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelection`. + """ + + return self.GetSelection() def GetColumnCount(self): @@ -4162,7 +4165,7 @@ _methods = ["GetIndent", "SetIndent", "GetSpacing", "SetSpacing", "GetImageList" "SetItemHasChildren", "SetItemBackgroundColour", "SetItemFont", "IsItemVisible", "HasChildren", "IsExpanded", "IsSelected", "IsBold", "GetCount", "GetChildrenCount", "GetRootItem", "GetSelection", "GetSelections", "GetItemParent", "GetFirstChild", "GetNextChild", "GetPrevChild", "GetLastChild", "GetNextSibling", - "GetPrevSibling", "GetNext", "GetFirstExpandedItem", "GetNextExpanded", "GetPrevExpanded", + "GetPrevSibling", "GetNext", "GetFirstExpandedItem", "GetNextExpanded", "GetPrevExpanded", "GetFocusedItem", "GetFirstVisibleItem", "GetNextVisible", "GetPrevVisible", "AddRoot", "PrependItem", "InsertItem", "AppendItem", "Delete", "DeleteChildren", "DeleteRoot", "Expand", "ExpandAll", "ExpandAllChildren", "Collapse", "CollapseAndReset", "Toggle", "Unselect", "UnselectAll", "SelectItem", "SelectAll", @@ -4250,6 +4253,7 @@ class HyperTreeList(wx.Control): :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetFirstExpandedItem` Returns the first item which is in the expanded state. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetFirstGradientColour` Returns the first gradient colour for gradient-style selections. :meth:`~wx.lib.agw.hypertreelist.TreeListMainWindow.GetFirstVisibleItem` Returns the first visible item. + GetFocusedItem Another name for :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelection` :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetGradientStyle` Returns the gradient style for gradient-style selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHilightFocusColour` Returns the colour used to highlight focused selected items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHilightNonFocusColour` Returns the colour used to highlight unfocused selected items.