.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. currentmodule:: wx.lib.agw.customtreectrl .. highlight:: python .. _wx.lib.agw.customtreectrl.CustomTreeCtrl: ========================================================================================================================================== |phoenix_title| **wx.lib.agw.customtreectrl.CustomTreeCtrl** ========================================================================================================================================== :class:`CustomTreeCtrl` is a class that mimics the behaviour of :class:`TreeCtrl`, with almost the same base functionalities plus some more enhancements. This class does not rely on the native control, as it is a full owner-drawn tree control. | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class CustomTreeCtrl:
| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/wx.lib.agw.customtreectrl.customtreectrl.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/../no_appearance.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/wx.lib.agw.customtreectrl.customtreectrl.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |super_classes| Known Superclasses ================================== :class:`wx.ScrolledWindow` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.__init__` Default class constructor. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AcceptsFocus` Can this window be given focus by mouse click? :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AddRoot` Adds a root item to the :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AdjustMyScrollbars` Internal method used to adjust the :class:`ScrolledWindow` scrollbars. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AppendItem` Appends an item as a last child of its parent. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AppendSeparator` Appends an horizontal line separator as a last child of its parent. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AssignButtonsImageList` Assigns the button image list. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AssignImageList` Assigns the normal image list. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AssignLeftImageList` Assigns the image list for :class:`CustomTreeCtrl` filled with images to be used on :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AssignStateImageList` Assigns the state image list. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AutoCheckChild` Transverses the tree and checks/unchecks the items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AutoCheckParent` Traverses up the tree and checks/unchecks parent items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.AutoToggleChild` Transverses the tree and toggles the items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CalculateLevel` Calculates the level of an item inside the tree hierarchy. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CalculateLineHeight` Calculates the base height for all lines in the tree. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CalculatePositions` Calculates all the positions of the visible items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CalculateSize` Calculates overall position and size of an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CheckChilds` Programmatically check/uncheck item children. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CheckItem` Actually checks/uncheks an item, sending (eventually) the two :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CheckItem2` Used internally to avoid ``EVT_TREE_ITEM_CHECKED`` events. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CheckSameLevel` Uncheck radio items which are on the same level of the checked one. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ChildrenClosing` We are about to destroy the item children. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Collapse` Collapse an item, sending a ``EVT_TREE_ITEM_COLLAPSING`` and :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.CollapseAndReset` Collapse the given item and deletes its children. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Delete` Deletes an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DeleteAllItems` Deletes all items in the :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DeleteChildren` Delete all the item's children. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DeleteItemWindow` Deletes the window associated to an item (if any). :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DoGetBestSize` Gets the size which best suits the window: for a control, it would be the :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DoInsertItem` Actually inserts an item in the tree. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DoSelectItem` Actually selects/unselects an item, sending ``EVT_TREE_SEL_CHANGING`` and :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DrawHorizontalGradient` Gradient fill from colour 1 to colour 2 from left to right. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DrawVerticalGradient` Gradient fill from colour 1 to colour 2 from top to bottom. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.DrawVistaRectangle` Draws the selected item(s) with the Windows Vista style. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Edit` Internal function. Starts the editing of an item label, sending a :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EditLabel` Starts editing an item label. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnableChildren` Enables/disables the item children. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnableItem` Enables/disables an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnableSelectionGradient` Globally enables/disables drawing of gradient selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnableSelectionVista` Globally enables/disables drawing of Windows Vista selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.EnsureVisible` Scrolls and/or expands items to ensure that the given item is visible. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Expand` Expands an item, sending a ``EVT_TREE_ITEM_EXPANDING`` and :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ExpandAll` Expands all :class:`CustomTreeCtrl` items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ExpandAllChildren` Expands all the items children of the input item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.FillArray` Internal function. Used to populate an array of selected items when :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.FindItem` Finds the first item starting with the given prefix after the given parent. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Freeze` Freeze :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetAGWWindowStyleFlag` Returns the :class:`CustomTreeCtrl` style. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetBackgroundImage` Returns the :class:`CustomTreeCtrl` background image (if any). :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetBorderPen` Returns the pen used to draw the selected item border. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetBoundingRect` Retrieves the rectangle bounding the item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetButtonsImageList` Returns the buttons image list associated with :class:`CustomTreeCtrl` (from :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetChildrenCount` Returns the item children count. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetConnectionPen` Returns the pen used to draw the connecting lines between items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetControlBmp` Returns a native looking checkbox or radio button bitmap. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetCount` Returns the global number of items in the tree. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetDisabledColour` Returns the colour for items in a disabled state. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetDragFullScreen` Returns whether built-in drag/drop will be full screen or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetEditControl` Returns a reference to the edit :class:`TreeTextCtrl` if the item is being edited or :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetFirstChild` Returns the item's first child and an integer value 'cookie'. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetFirstGradientColour` Returns the first gradient colour for gradient-style selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetFirstVisibleItem` Returns the first visible item. :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. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHyperTextFont` Returns the font used to render hypertext items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHyperTextNewColour` Returns the colour used to render a non-visited hypertext item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetHyperTextVisitedColour` Returns the colour used to render a visited hypertext item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetImageList` Returns the normal image list associated with :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetImageListCheck` Returns the image list used to build the check/radio buttons in :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetIndent` Returns the item indentation, in pixels. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItem3StateValue` Gets the state of a 3-state checkbox item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemBackgroundColour` Returns the item background colour. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemFont` Returns the item font. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemImage` Returns the item image. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemLeftImage` Returns the item leftmost image, i.e. the image associated to the item on the leftmost :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemParent` Returns the item parent (can be ``None`` for root items). :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemSize` Returns the horizontal space available in :class:`CustomTreeCtrl`, in pixels, to draw this item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemText` Returns the item text. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemTextColour` Returns the item text colour or separator horizontal line colour. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemType` Returns the item type. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemVisited` Returns whether an hypertext item was visited. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemWindow` Returns the window associated to the item (if any). :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetItemWindowEnabled` Returns whether the window associated to the item is enabled. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetLastChild` Returns the item last child. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetLeftImageList` Returns the image list for :class:`CustomTreeCtrl` filled with images to be used on :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetLineHeight` Returns the line height for the given item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetMaxWidth` Returns the maximum width of the :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNext` Returns the next item. Only for internal use right now. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextActiveItem` Returns the next active item. Used Internally at present. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextChild` Returns the item's next child. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextExpanded` Returns the next expanded item after the input one. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextShown` Returns the next displayed item in the tree. This is either the first :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextSibling` Returns the next sibling of an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetNextVisible` Returns the next visible item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPrev` Returns the previous item. Only for internal use right now. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPrevExpanded` Returns the previous expanded item before the input one. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPrevShown` Returns the previous displayed item in the tree. This is either the :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPrevSibling` Returns the previous sibling of an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPrevVisible` Returns the previous visible item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetPyData` Returns the data associated to an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetRootItem` Returns the root item, an instance of :class:`GenericTreeItem`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSecondGradientColour` Returns the second gradient colour for gradient-style selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelection` Returns the current selected item (i.e. focused item). :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSelections` Returns a list of selected items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSeparatorColour` Returns the pen colour for separator-type items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetSpacing` Returns the spacing between the start and the text, in pixels. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.GetStateImageList` Returns the state image list associated with :class:`CustomTreeCtrl` (from which :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HandleHyperLink` Handles the hyperlink items, sending the ``EVT_TREE_ITEM_HYPERLINK`` event. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HasAGWFlag` Returns ``True`` if :class:`CustomTreeCtrl` has the `flag` bit set. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HasButtons` Returns whether :class:`CustomTreeCtrl` has the ``TR_HAS_BUTTONS`` flag set. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HasChildren` Returns whether an item has children or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HideItem` Hides/shows an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HideItemWindows` Hide all windows belonging to the item and its children. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HideWindows` Hides the windows associated to the items. Used internally. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.HitTest` Calculates which (if any) item is under the given point, returning the tree item :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.InsertItem` Inserts an item after the given previous. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.InsertItemByIndex` Inserts an item after the given previous. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.InsertItemByItem` Inserts an item after the given previous. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.InsertSeparator` Inserts a separator item after the given previous. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsBold` Returns whether the item font is bold or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsDescendantOf` Checks if the given item is under another one in the tree hierarchy. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsExpanded` Returns whether the item is expanded or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItalic` Returns whether the item font is italic or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItem3State` Returns whether or not the checkbox item is a 3-state checkbox. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItemChecked` Returns whether an item is checked or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItemEnabled` Returns whether an item is enabled or disabled. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItemHyperText` Returns whether an item is hypertext or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsItemSeparator` Returns whether an item is of separator type or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsSelected` Returns whether the item is selected or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.IsVisible` Returns whether the item is visible or not (i.e., its hierarchy is expanded :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ItemHasChildren` Returns whether the item has children or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnAcceptEdit` Called by :class:`TreeTextCtrl`, to accept the changes and to send the :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnCancelEdit` Called by :class:`TreeTextCtrl`, to cancel the changes and to send the :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnCompareItems` Returns whether 2 items have the same text. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnDestroy` Handles the ``wx.EVT_WINDOW_DESTROY`` event for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnEditTimer` The timer for editing has expired. Start editing. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnEraseBackground` Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnGetToolTip` Process the tooltip event, to speed up event processing. Does not actually :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnInternalIdle` This method is normally only used internally, but sometimes an application :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnKeyDown` Handles the ``wx.EVT_KEY_DOWN`` event for :class:`CustomTreeCtrl`, sending a :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnKillFocus` Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnMouse` Handles a bunch of ``wx.EVT_MOUSE_EVENTS`` events for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnPaint` Handles the ``wx.EVT_PAINT`` event for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnSetFocus` Handles the ``wx.EVT_SET_FOCUS`` event for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.OnSize` Handles the ``wx.EVT_SIZE`` event for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.PaintItem` Actually draws an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.PaintLevel` Paint a level in the hierarchy of :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.PrependItem` Prepends an item as a first child of parent. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.PrependSeparator` Prepends a separator item as a first child of parent. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.RecurseOnChildren` Recurses over all the children of the spcified items, calculating their :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.RefreshItemWithWindows` Refreshes the items with which a window is associated. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.RefreshLine` Refreshes a damaged item line. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.RefreshSelected` Refreshes a damaged selected item line. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.RefreshSelectedUnder` Refreshes the selected items under the given item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.RefreshSubtree` Refreshes a damaged subtree of an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ResetEditControl` Called by :class:`TreeTextCtrl` when it marks itself for deletion. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ScrollTo` Scrolls the specified item into view. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SelectAll` Selects all the item in the tree. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SelectAllChildren` Selects all the children of the given item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SelectItem` Selects/deselects an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SelectItemRange` Selects all the items between `item1` and `item2`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SendDeleteEvent` Actually sends the ``EVT_TREE_DELETE_ITEM`` event. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetAGWWindowStyleFlag` Sets the :class:`CustomTreeCtrl` window style. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetBackgroundColour` Changes the background colour of :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetBackgroundImage` Sets the :class:`CustomTreeCtrl` background image. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetBorderPen` Sets the pen used to draw the selected item border. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetButtonsImageList` Sets the buttons image list for :class:`CustomTreeCtrl` (from which application-defined :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetConnectionPen` Sets the pen used to draw the connecting lines between items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetDisabledColour` Sets the colour for items in a disabled state. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetDragFullScreen` Sets whether a drag operation will be performed full screen or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetFirstGradientColour` Sets the first gradient colour for gradient-style selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetFont` Sets the :class:`CustomTreeCtrl` font. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetForegroundColour` Changes the foreground colour of :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetGradientStyle` Sets the gradient style for gradient-style selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHilightFocusColour` Sets the colour used to highlight focused selected items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHilightNonFocusColour` Sets the colour used to highlight unfocused selected items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHyperTextFont` Sets the font used to render hypertext items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHyperTextNewColour` Sets the colour used to render a non-visited hypertext item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetHyperTextVisitedColour` Sets the colour used to render a visited hypertext item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetImageList` Sets the normal image list for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetImageListCheck` Sets the checkbox/radiobutton image list. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetIndent` Sets the indentation for :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItem3State` Sets whether the item has a 3-state value checkbox assigned to it or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItem3StateValue` Sets the checkbox item to the given `state`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemBackgroundColour` Sets the item background colour. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemBold` Sets the item font as bold/unbold. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemDropHighlight` Gives the item the visual feedback for drag and drop operations. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemFont` Sets the item font. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemHasChildren` Forces the appearance/disappearance of the button next to the item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemHyperText` Sets whether the item is hypertext or not. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemImage` Sets the item image, depending on the item state. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemItalic` Sets the item font as italic/non-italic. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemLeftImage` Sets the item leftmost image, i.e. the image associated to the item on the leftmost :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemText` Sets the item text. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemTextColour` Sets the item text colour or separator horizontal line colour. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemType` Sets the item type. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemVisited` Sets whether an hypertext item was visited. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemWindow` Sets the window for the given item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetItemWindowEnabled` Enables/disables the window associated to the item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetLeftImageList` Sets the image list for :class:`CustomTreeCtrl` filled with images to be used on :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetPyData` Sets the data associated to an item. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetSecondGradientColour` Sets the second gradient colour for gradient-style selections. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetSeparatorColour` Sets the pen colour for separator-type items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetSpacing` Sets the spacing between items in :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SetStateImageList` Sets the state image list for :class:`CustomTreeCtrl` (from which application-defined :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ShouldInheritColours` Return ``True`` from here to allow the colours of this window to be :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.SortChildren` Sorts the children of the given item using the :meth:`~CustomTreeCtrl.OnCompareItems` method of :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.TagAllChildrenUntilLast` Used internally. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.TagNextChildren` Used internally. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Thaw` Thaw :class:`CustomTreeCtrl`. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.TileBackground` Tiles the background image to fill all the available area. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Toggle` Toggles the item state (collapsed/expanded). :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.ToggleItemSelection` Toggles the item selection. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.UnCheckRadioParent` Used internally to handle radio node parent correctly. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.Unselect` Unselects the current selection. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.UnselectAll` Unselect all the items. :meth:`~wx.lib.agw.customtreectrl.CustomTreeCtrl.UnselectAllChildren` Unselects all the children of the given item. ================================================================================ ================================================================================ | |api| Class API =============== .. class:: CustomTreeCtrl(wx.ScrolledWindow) :class:`CustomTreeCtrl` is a class that mimics the behaviour of :class:`TreeCtrl`, with almost the same base functionalities plus some more enhancements. This class does not rely on the native control, as it is a full owner-drawn tree control. .. method:: __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, agwStyle=TR_DEFAULT_STYLE, validator=wx.DefaultValidator, name="CustomTreeCtrl") Default class constructor. :param wx.Window `parent`: parent window. Must not be ``None``; :param integer `id`: window identifier. A value of -1 indicates a default value; :param `pos`: the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform; :type `pos`: tuple or :class:`wx.Point` :param `size`: the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform; :type `size`: tuple or :class:`wx.Size` :param integer `style`: the underlying :class:`ScrolledWindow` style; :param integer `agwStyle`: can be a combination of various bits. See :mod:`~wx.lib.agw.customtreectrl` for a full list of flags. :param wx.Validator `validator`: window validator; :param string `name`: window name. .. method:: AcceptsFocus(self) Can this window be given focus by mouse click? .. note:: This method always returns ``True`` as we always accept focus from mouse click. .. note:: Overridden from :class:`ScrolledWindow`. .. method:: AddRoot(self, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None, on_the_right=True) Adds a root item to the :class:`CustomTreeCtrl`. :param string `text`: the item text label; :param integer `ct_type`: the item type (see :meth:`~CustomTreeCtrl.SetItemType` for a list of valid item types); :param `wnd`: if not ``None``, a non-toplevel window to show next to the item, any subclass of :class:`wx.Window` except top-level windows; :param integer `image`: an index within the normal image list specifying the image to use for the item in unselected state; :param integer `selImage`: an index within the normal image list specifying the image to use for the item in selected state; if `image` > -1 and `selImage` is -1, the same image is used for both selected and unselected items; :param object `data`: associate the given Python object `data` with the item. :param bool `on_the_right`: ``True`` positions the window on the right of text, ``False`` on the left of text and overlapping the image. :return: An instance of :class:`GenericTreeItem` upon successful insertion. :raise: `Exception` in the following cases: - There already is a root item in the tree; - The item window is not ``None`` but the ``TR_HAS_VARIABLE_ROW_HEIGHT`` flag has not been set for :class:`CustomTreeCtrl`; - The item has multiline text (with line-breaks in it) but the ``TR_HAS_VARIABLE_ROW_HEIGHT`` flag has not been set for :class:`CustomTreeCtrl`; - The `ct_type` attribute is less than ``0`` or greater than ``2``. .. warning:: Only one root is allowed to exist in any given instance of :class:`CustomTreeCtrl`. .. method:: AdjustMyScrollbars(self) Internal method used to adjust the :class:`ScrolledWindow` scrollbars. .. method:: AppendItem(self, parentId, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None, on_the_right=True) Appends an item as a last child of its parent. :param `parentId`: an instance of :class:`GenericTreeItem` representing the item's parent; :param string `text`: the item text label; :param integer `ct_type`: the item type (see :meth:`~CustomTreeCtrl.SetItemType` for a list of valid item types); :param `wnd`: if not ``None``, a non-toplevel window to show next to the item, any subclass of :class:`wx.Window`; :param integer `image`: an index within the normal image list specifying the image to use for the item in unselected state; :param integer `selImage`: an index within the normal image list specifying the image to use for the item in selected state; if `image` > -1 and `selImage` is -1, the same image is used for both selected and unselected items; :param object `data`: associate the given Python object `data` with the item. :param bool `on_the_right`: ``True`` positions the window on the right of text, ``False`` on the left of text and overlapping the image. :return: An instance of :class:`GenericTreeItem` upon successful insertion. .. seealso:: :meth:`~CustomTreeCtrl.DoInsertItem` for possible exceptions generated by this method. .. method:: AppendSeparator(self, parentId) Appends an horizontal line separator as a last child of its parent. :param `parentId`: an instance of :class:`GenericTreeItem` representing the separator's parent. :return: An instance of :class:`GenericTreeItem` upon successful insertion. .. seealso:: :meth:`~CustomTreeCtrl.DoInsertItem` for possible exceptions generated by this method. .. method:: AssignButtonsImageList(self, imageList) Assigns the button image list. :param `imageList`: an instance of :class:`wx.ImageList`. .. method:: AssignImageList(self, imageList) Assigns the normal image list. :param `imageList`: an instance of :class:`wx.ImageList`. .. method:: AssignLeftImageList(self, imageList) Assigns the image list for :class:`CustomTreeCtrl` filled with images to be used on the leftmost part of the client area. Any item can have a leftmost image associated with it. :param `imageList`: an instance of :class:`wx.ImageList`. .. method:: AssignStateImageList(self, imageList) Assigns the state image list. :param `imageList`: an instance of :class:`wx.ImageList`. .. method:: AutoCheckChild(self, item, checked) Transverses the tree and checks/unchecks the items. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `checked`: ``True`` to check an item, ``False`` to uncheck it. .. note:: This method is meaningful only for checkbox-like and radiobutton-like items. .. method:: AutoCheckParent(self, item, checked) Traverses up the tree and checks/unchecks parent items. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `checked`: ``True`` to check an item, ``False`` to uncheck it. .. note:: This method is meaningful only for checkbox-like and radiobutton-like items. .. method:: AutoToggleChild(self, item) Transverses the tree and toggles the items. :param `item`: an instance of :class:`GenericTreeItem`. .. note:: This method is meaningful only for checkbox-like and radiobutton-like items. .. method:: CalculateLevel(self, item, dc, level, y, align=0) Calculates the level of an item inside the tree hierarchy. :param `item`: an instance of :class:`GenericTreeItem`; :param `dc`: an instance of :class:`wx.DC`; :param integer `level`: the item level in the tree hierarchy; :param integer `y`: the current vertical position inside the :class:`ScrolledWindow`; :param integer `align`: an integer specifying the alignment type: =============== ========================================= `align` Value Description =============== ========================================= 0 No horizontal alignment of windows (in items with windows). 1 Windows (in items with windows) are aligned at the same horizontal position. 2 Windows (in items with windows) are aligned at the rightmost edge of :class:`CustomTreeCtrl`. =============== ========================================= :return: The new `y` vertical position inside the :class:`ScrolledWindow`. .. method:: CalculateLineHeight(self) Calculates the base height for all lines in the tree. Only used if the TR_HAS_VARIABLE_ROW_HEIGHT style is not used. This base line height gets adjusted to the max line height of all items as they are displayed. All rows use this largest height until this method is called to reset it. .. method:: CalculatePositions(self) Calculates all the positions of the visible items. .. method:: CalculateSize(self, item, dc, level=-1, align=0) Calculates overall position and size of an item. :param `item`: an instance of :class:`GenericTreeItem`; :param `dc`: an instance of :class:`wx.DC`; :param integer `level`: the item level in the tree hierarchy; :param integer `align`: an integer specifying the alignment type: =============== ========================================= `align` Value Description =============== ========================================= 0 No horizontal alignment of windows (in items with windows). 1 Windows (in items with windows) are aligned at the same horizontal position. 2 Windows (in items with windows) are aligned at the rightmost edge of :class:`CustomTreeCtrl`. =============== ========================================= .. method:: CheckChilds(self, item, checked=True) Programmatically check/uncheck item children. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `checked`: ``True`` to check an item, ``False`` to uncheck it. .. note:: This method is meaningful only for checkbox-like and radiobutton-like items. .. note:: This method does not generate ``EVT_TREE_ITEM_CHECKING`` and ``EVT_TREE_ITEM_CHECKED`` events. .. method:: CheckItem(self, item, checked=True) Actually checks/uncheks an item, sending (eventually) the two events ``EVT_TREE_ITEM_CHECKING`` and ``EVT_TREE_ITEM_CHECKED``. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `checked`: for a radiobutton-type item, ``True`` to check it, ``False`` to uncheck it. For a checkbox-type item, it can be one of ``wx.CHK_UNCHECKED`` when the checkbox is unchecked, ``wx.CHK_CHECKED`` when it is checked and ``wx.CHK_UNDETERMINED`` when it's in the undetermined state. .. method:: CheckItem2(self, item, checked=True, torefresh=False) Used internally to avoid ``EVT_TREE_ITEM_CHECKED`` events. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `checked`: ``True`` to check an item, ``False`` to uncheck it; :param bool `torefresh`: whether to redraw the item or not. .. method:: CheckSameLevel(self, item, checked=False) Uncheck radio items which are on the same level of the checked one. Used internally. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `checked`: ``True`` to check an item, ``False`` to uncheck it. .. note:: This method is meaningful only for radiobutton-like items. .. method:: ChildrenClosing(self, item) We are about to destroy the item children. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: Collapse(self, item) Collapse an item, sending a ``EVT_TREE_ITEM_COLLAPSING`` and ``EVT_TREE_ITEM_COLLAPSED`` events. :param `item`: an instance of :class:`GenericTreeItem`. :raise: `Exception` if you try to collapse a hidden root (i.e., when the ``TR_HIDE_ROOT`` style is set for :class:`CustomTreeCtrl`). .. method:: CollapseAndReset(self, item) Collapse the given item and deletes its children. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: Delete(self, item) Deletes an item. :param `item`: an instance of :class:`GenericTreeItem`. .. note:: This method sends the ``EVT_TREE_DELETE_ITEM`` event. .. method:: DeleteAllItems(self) Deletes all items in the :class:`CustomTreeCtrl`. .. method:: DeleteChildren(self, item) Delete all the item's children. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: DeleteItemWindow(self, item) Deletes the window associated to an item (if any). :param `item`: an instance of :class:`GenericTreeItem`. .. method:: DoGetBestSize(self) Gets the size which best suits the window: for a control, it would be the minimal size which doesn't truncate the control, for a panel - the same size as it would have after a call to `Fit()`. :return: An instance of :class:`wx.Size`. .. note:: Overridden from :class:`ScrolledWindow`. .. method:: DoInsertItem(self, parentId, previous, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None, separator=False, on_the_right=True) Actually inserts an item in the tree. :param `parentId`: an instance of :class:`GenericTreeItem` representing the item's parent; :param integer `previous`: the index at which we should insert the item; :param string `text`: the item text label; :param integer `ct_type`: the item type (see :meth:`~CustomTreeCtrl.SetItemType` for a list of valid item types); :param `wnd`: if not ``None``, a non-toplevel window to show next to the item, any subclass of :class:`wx.Window` except top-level windows; :param integer `image`: an index within the normal image list specifying the image to use for the item in unselected state; :param integer `selImage`: an index within the normal image list specifying the image to use for the item in selected state; if `image` > -1 and `selImage` is -1, the same image is used for both selected and unselected items; :param object `data`: associate the given Python object `data` with the item; :param bool `separator`: ``True`` if the item is a separator, ``False`` otherwise. :param bool `on_the_right`: ``True`` positions the window on the right of text, ``False`` on the left of text and overlapping the image. :return: An instance of :class:`GenericTreeItem` upon successful insertion. :raise: `Exception` in the following cases: - The item window is not ``None`` but the ``TR_HAS_VARIABLE_ROW_HEIGHT`` flag has not been set for :class:`CustomTreeCtrl`; - The item has multiline text (with line-breaks in it) but the ``TR_HAS_VARIABLE_ROW_HEIGHT`` flag has not been set for :class:`CustomTreeCtrl`; - The `ct_type` attribute is less than ``0`` or greater than ``2``; - The parent item is a separator; - The item is a separator but it has text or an associated window. .. note:: Separator items should not have children, text labels or an associated window. .. method:: DoSelectItem(self, item, unselect_others=True, extended_select=False, from_key=False) Actually selects/unselects an item, sending ``EVT_TREE_SEL_CHANGING`` and ``EVT_TREE_SEL_CHANGED`` events. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `unselect_others`: if ``True``, all the other selected items are unselected. :param bool `extended_select`: ``True`` if the :class:`CustomTreeCtrl` is using the ``TR_EXTENDED`` style; :param bool `from_key`: ``True`` to indicate that the selection was made via a keyboard key, ``False`` if it was a mouse selection. .. method:: DrawHorizontalGradient(self, dc, rect, hasfocus) Gradient fill from colour 1 to colour 2 from left to right. :param `dc`: an instance of :class:`wx.DC`; :param wx.Rect `rect`: the rectangle to be filled with the gradient shading; :param bool `hasfocus`: ``True`` if the main :class:`CustomTreeCtrl` has focus, ``False`` otherwise. .. method:: DrawVerticalGradient(self, dc, rect, hasfocus) Gradient fill from colour 1 to colour 2 from top to bottom. :param `dc`: an instance of :class:`wx.DC`; :param wx.Rect `rect`: the rectangle to be filled with the gradient shading; :param bool `hasfocus`: ``True`` if the main :class:`CustomTreeCtrl` has focus, ``False`` otherwise. .. method:: DrawVistaRectangle(self, dc, rect, hasfocus) Draws the selected item(s) with the Windows Vista style. :param `dc`: an instance of :class:`wx.DC`; :param wx.Rect `rect`: the rectangle to be filled with the gradient shading; :param bool `hasfocus`: ``True`` if the main :class:`CustomTreeCtrl` has focus, ``False`` otherwise. .. method:: Edit(self, item) Internal function. Starts the editing of an item label, sending a ``EVT_TREE_BEGIN_LABEL_EDIT`` event. :param `item`: an instance of :class:`GenericTreeItem`. .. warning:: Separator-type items can not be edited. .. method:: EditLabel(self, item) Starts editing an item label. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: EnableChildren(self, item, enable=True) Enables/disables the item children. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `enable`: ``True`` to enable the children, ``False`` to disable them. .. note:: This method is used internally. .. method:: EnableItem(self, item, enable=True, torefresh=True) Enables/disables an item. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `enable`: ``True`` to enable the item, ``False`` to disable it; :param bool `torefresh`: whether to redraw the item or not. .. method:: EnableSelectionGradient(self, enable=True) Globally enables/disables drawing of gradient selections. :param bool `enable`: ``True`` to enable gradient-style selections, ``False`` to disable it. .. note:: Calling this method disables any Vista-style selection previously enabled. .. method:: EnableSelectionVista(self, enable=True) Globally enables/disables drawing of Windows Vista selections. :param bool `enable`: ``True`` to enable Vista-style selections, ``False`` to disable it. .. note:: Calling this method disables any gradient-style selection previously enabled. .. method:: EnsureVisible(self, item) Scrolls and/or expands items to ensure that the given item is visible. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: Expand(self, item) Expands an item, sending a ``EVT_TREE_ITEM_EXPANDING`` and ``EVT_TREE_ITEM_EXPANDED`` events. :param `item`: an instance of :class:`GenericTreeItem`. :raise: `Exception` if you try to expand a hidden root (i.e., when the ``TR_HIDE_ROOT`` style is set for :class:`CustomTreeCtrl`). .. method:: ExpandAll(self) Expands all :class:`CustomTreeCtrl` items. .. note:: This method suppresses the ``EVT_TREE_ITEM_EXPANDING`` and ``EVT_TREE_ITEM_EXPANDED`` events because expanding many items int the control would be too slow then. .. method:: ExpandAllChildren(self, item) Expands all the items children of the input item. :param `item`: an instance of :class:`GenericTreeItem`. .. note:: This method suppresses the ``EVT_TREE_ITEM_EXPANDING`` and ``EVT_TREE_ITEM_EXPANDED`` events because expanding many items int the control would be too slow then. .. method:: FillArray(self, item, array=[]) Internal function. Used to populate an array of selected items when the style ``TR_MULTIPLE`` is used. :param `item`: an instance of :class:`GenericTreeItem`; :param list `array`: a Python list containing the selected items. :return: A Python list containing the selected items. .. method:: FindItem(self, idParent, prefixOrig) Finds the first item starting with the given prefix after the given parent. :param integer `idParent`: an instance of :class:`GenericTreeItem`; :param string `prefixOrig`: a string containing the item text prefix. :return: An instance of :class:`GenericTreeItem` or ``None`` if no item has been found. .. method:: Freeze(self) Freeze :class:`CustomTreeCtrl`. Freezes the window or, in other words, prevents any updates from taking place on screen, the window is not redrawn at all. :meth:`~Thaw` must be called to re-enable window redrawing. Calls to these two functions may be nested. .. note:: This method is useful for visual appearance optimization (for example, it is a good idea to use it before doing many large text insertions in a row into a :class:`TextCtrl` under wxGTK) but is not implemented on all platforms nor for all controls so it is mostly just a hint to wxWidgets and not a mandatory directive. .. method:: GetAGWWindowStyleFlag(self) Returns the :class:`CustomTreeCtrl` style. .. seealso:: The :meth:`~CustomTreeCtrl.__init__` method for a list of possible style flags. .. method:: GetBackgroundImage(self) Returns the :class:`CustomTreeCtrl` background image (if any). :return: An instance of :class:`wx.Bitmap` if a background image is present, ``None`` otherwise. .. note:: At present, the background image can only be used in "tile" mode. .. todo:: Support background images also in stretch and centered modes. .. method:: GetBorderPen(self) Returns the pen used to draw the selected item border. :return: An instance of :class:`wx.Pen`. .. note:: The border pen is not used if the Windows Vista selection style is applied. .. method:: GetBoundingRect(self, item, textOnly=False) Retrieves the rectangle bounding the item. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `textOnly`: if ``True``, only the rectangle around the item's label will be returned, otherwise the item's image is also taken into account. :return: An instance of :class:`wx.Rect`. .. note:: The rectangle coordinates are logical, not physical ones. So, for example, the `x` coordinate may be negative if the tree has a horizontal scrollbar and its position is not ``0``. .. warning:: The ``textOnly`` flag is currently ignored and this method always returns the rectangle including the item's image, checkbox, and window (if they exist) along with the item's text. A separator's bounding box stretches the width of the entire client area. The height may be 0 for newly added items until :meth:`CustomTreeCtrl.CalculateSize` is called while the tree is not frozen. .. method:: GetButtonsImageList(self) Returns the buttons image list associated with :class:`CustomTreeCtrl` (from which application-defined button images are taken). :return: An instance of :class:`wx.ImageList`. .. method:: GetChildrenCount(self, item, recursively=True) Returns the item children count. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `recursively`: if ``True``, returns the total number of descendants, otherwise only one level of children is counted. .. method:: GetConnectionPen(self) Returns the pen used to draw the connecting lines between items. :return: An instance of :class:`wx.Pen`. .. method:: GetControlBmp(self, checkbox=True, checked=False, enabled=True, x=16, y=16) Returns a native looking checkbox or radio button bitmap. :param bool `checkbox`: ``True`` to get a checkbox image, ``False`` for a radiobutton one; :param bool `checked`: ``True`` if the control is marked, ``False`` if it is not; :param bool `enabled`: ``True`` if the control is enabled, ``False`` if it is not; :param integer `x`: the width of the bitmap; :param integer `y`: the height of the bitmap. :return: An instance of :class:`wx.Bitmap`, representing a native looking checkbox or radiobutton. .. method:: GetCount(self) Returns the global number of items in the tree. .. method:: GetDisabledColour(self) Returns the colour for items in a disabled state. :return: An instance of :class:`wx.Colour`. .. method:: GetDragFullScreen(self) Returns whether built-in drag/drop will be full screen or not. :return: ``True`` if the drag/drop operation will be full screen, or ``False`` if only within the tree. .. method:: GetEditControl(self) Returns a reference to the edit :class:`TreeTextCtrl` if the item is being edited or ``None`` otherwise (it is assumed that no more than one item may be edited simultaneously). .. method:: GetFirstChild(self, item) Returns the item's first child and an integer value 'cookie'. Call :meth:`~CustomTreeCtrl.GetNextChild` for the next child using this very 'cookie' return value as an input. :param `item`: an instance of :class:`GenericTreeItem`. :return: A tuple with the first value being an instance of :class:`GenericTreeItem` or ``None`` if there are no further children, and as second value an integer parameter 'cookie'. .. note:: This method returns ``None`` if there are no further children. .. method:: GetFirstGradientColour(self) Returns the first gradient colour for gradient-style selections. :return: An instance of :class:`wx.Colour`. .. method:: GetFirstVisibleItem(self) Returns the first visible item. :return: An instance of :class:`GenericTreeItem` or ``None`` if there are no visible items. .. method:: GetGradientStyle(self) Returns the gradient style for gradient-style selections. :return: ``0`` for horizontal gradient-style selections, ``1`` for vertical gradient-style selections. .. method:: GetHilightFocusColour(self) Returns the colour used to highlight focused selected items. :return: An instance of :class:`wx.Colour`. .. note:: This is used only if gradient and Windows Vista selection styles are disabled. .. method:: GetHilightNonFocusColour(self) Returns the colour used to highlight unfocused selected items. :return: An instance of :class:`wx.Colour`. .. note:: This is used only if gradient and Windows Vista selection styles are disabled. .. method:: GetHyperTextFont(self) Returns the font used to render hypertext items. :return: An instance of :class:`wx.Font`. .. note:: This method is meaningful only for hypertext-like items. .. method:: GetHyperTextNewColour(self) Returns the colour used to render a non-visited hypertext item. :return: An instance of :class:`wx.Colour`. .. note:: This method is meaningful only for hypertext-like items. .. method:: GetHyperTextVisitedColour(self) Returns the colour used to render a visited hypertext item. :return: An instance of :class:`wx.Colour`. .. note:: This method is meaningful only for hypertext-like items. .. method:: GetImageList(self) Returns the normal image list associated with :class:`CustomTreeCtrl`. :return: An instance of :class:`wx.ImageList`. .. method:: GetImageListCheck(self) Returns the image list used to build the check/radio buttons in :class:`CustomTreeCtrl`. :return: An instance of :class:`wx.ImageList`. .. method:: GetIndent(self) Returns the item indentation, in pixels. .. method:: GetItem3StateValue(self, item) Gets the state of a 3-state checkbox item. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``wx.CHK_UNCHECKED`` when the checkbox is unchecked, ``wx.CHK_CHECKED`` when it is checked and ``wx.CHK_UNDETERMINED`` when it's in the undetermined state. .. note:: This method raises an exception when the function is used with a 2-state checkbox item. .. note:: This method is meaningful only for checkbox-like items. .. method:: GetItemBackgroundColour(self, item) Returns the item background colour. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`wx.Colour`. .. method:: GetItemFont(self, item) Returns the item font. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`wx.Font`. .. method:: GetItemImage(self, item, which=TreeItemIcon_Normal) Returns the item image. :param `item`: an instance of :class:`GenericTreeItem`; :param integer `which`: can be one of the following bits: ================================= ======================== Item State Description ================================= ======================== ``TreeItemIcon_Normal`` To get the normal item image ``TreeItemIcon_Selected`` To get the selected item image (i.e. the image which is shown when the item is currently selected) ``TreeItemIcon_Expanded`` To get the expanded image (this only makes sense for items which have children - then this image is shown when the item is expanded and the normal image is shown when it is collapsed) ``TreeItemIcon_SelectedExpanded`` To get the selected expanded image (which is shown when an expanded item is currently selected) ================================= ======================== :return: An integer index that can be used to retrieve the item image inside a :class:`wx.ImageList`. .. method:: GetItemLeftImage(self, item) Returns the item leftmost image, i.e. the image associated to the item on the leftmost part of the :class:`CustomTreeCtrl` client area. :param `item`: an instance of :class:`GenericTreeItem`. :return: An integer index that can be used to retrieve the item leftmost image inside a :class:`wx.ImageList`. .. method:: GetItemParent(self, item) Returns the item parent (can be ``None`` for root items). :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`GenericTreeItem` or ``None`` for root items. .. method:: GetItemSize(self, item) Returns the horizontal space available in :class:`CustomTreeCtrl`, in pixels, to draw this item. :param `item`: an instance of :class:`GenericTreeItem`. .. versionadded:: 0.9.3 .. method:: GetItemText(self, item) Returns the item text. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: GetItemTextColour(self, item) Returns the item text colour or separator horizontal line colour. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`wx.Colour`. .. method:: GetItemType(self, item) Returns the item type. :param `item`: an instance of :class:`GenericTreeItem`. :return: An integer representing the item type. .. seealso:: :meth:`~CustomTreeCtrl.SetItemType` for a description of valid item types. .. method:: GetItemVisited(self, item) Returns whether an hypertext item was visited. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the hypertext item has been visited, ``False`` otherwise. .. note:: This method is meaningful only for hypertext-like items. .. method:: GetItemWindow(self, item) Returns the window associated to the item (if any). :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`wx.Window` if the item has an associated window, ``None`` otherwise. .. method:: GetItemWindowEnabled(self, item) Returns whether the window associated to the item is enabled. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item has an associated window and this window is enabled, ``False`` in all other cases. .. method:: GetLastChild(self, item) Returns the item last child. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`GenericTreeItem` or ``None`` if there are no further children. .. method:: GetLeftImageList(self) Returns the image list for :class:`CustomTreeCtrl` filled with images to be used on the leftmost part of the client area. Any item can have a leftmost image associated with it. :return: An instance of :class:`wx.ImageList`. .. method:: GetLineHeight(self, item) Returns the line height for the given item. :param `item`: an instance of :class:`GenericTreeItem`. :return: the item height, in pixels. .. method:: GetMaxWidth(self, respect_expansion_state=True) Returns the maximum width of the :class:`CustomTreeCtrl`. :param bool `respect_expansion_state`: if ``True``, only the expanded items (and their children) will be measured. Otherwise all the items are expanded and their width measured. :return: the maximum width of :class:`CustomTreeCtrl`, in pixels. .. method:: GetNext(self, item) Returns the next item. Only for internal use right now. :return: An instance of :class:`GenericTreeItem` or ``None`` if there are no further items. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: GetNextActiveItem(self, item, down=True) Returns the next active item. Used Internally at present. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `down`: ``True`` to search downwards in the hierarchy for an active item, ``False`` to search upwards. :return: An instance of :class:`GenericTreeItem` if an active item has been found or ``None`` if none has been found. .. method:: GetNextChild(self, item, cookie) Returns the item's next child. :param `item`: an instance of :class:`GenericTreeItem`; :param `cookie`: a parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). :return: A tuple with the first value being an instance of :class:`GenericTreeItem` or ``None`` if there are no further children, and as second value an integer parameter 'cookie'. .. note:: This method returns ``None`` if there are no further children. .. method:: GetNextExpanded(self, item) Returns the next expanded item after the input one. :param `item`: an instance of :class:`TreeListItem`. .. method:: GetNextShown(self, item) Returns the next displayed item in the tree. This is either the first child of the item (if it is expanded and has children) or its next sibling. If there is no next sibling the tree is walked backwards until a next sibling for one of its parents is found. :param `item`: an instance of :class:`GenericTreeItem`; :return: An instance of :class:`GenericTreeItem` or ``None`` if no item follows this one. .. method:: GetNextSibling(self, item) Returns the next sibling of an item. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`GenericTreeItem` or ``None`` if there are no further siblings. .. note:: This method returns ``None`` if there are no further siblings. .. method:: GetNextVisible(self, item) Returns the next visible item. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`GenericTreeItem` or ``None`` if there are no next visible items. .. method:: GetPrev(self, item) Returns the previous item. Only for internal use right now. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`GenericTreeItem` .. method:: GetPrevExpanded(self, item) Returns the previous expanded item before the input one. :param `item`: an instance of :class:`TreeListItem`. .. method:: GetPrevShown(self, item) Returns the previous displayed item in the tree. This is either the last displayed child of its previous sibling, or its parent item. :param `item`: an instance of :class:`GenericTreeItem`; :return: An instance of :class:`GenericTreeItem` or ``None`` if no previous item found (root). .. method:: GetPrevSibling(self, item) Returns the previous sibling of an item. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`GenericTreeItem` or ``None`` if there are no further siblings. .. note:: This method returns ``None`` if there are no further siblings. .. method:: GetPrevVisible(self, item) Returns the previous visible item. :param `item`: an instance of :class:`GenericTreeItem`. :return: An instance of :class:`GenericTreeItem` or ``None`` if there are no previous visible items. .. method:: GetPyData(self, item) Returns the data associated to an item. :param `item`: an instance of :class:`GenericTreeItem`. :return: A Python object representing the item data, or ``None`` if no data has been assigned to this item. .. method:: GetRootItem(self) Returns the root item, an instance of :class:`GenericTreeItem`. .. method:: GetSecondGradientColour(self) Returns the second gradient colour for gradient-style selections. :return: An instance of :class:`wx.Colour`. .. method:: GetSelection(self) Returns the current selected item (i.e. focused item). :return: An instance of :class:`GenericTreeItem`. .. note:: Similar to GetFocusedItem of wx.TreeCtrl. Use :meth:`~CustomTreeCtrl.GetSelections` for obtaining all items selected in multiple-selection trees (i.e. TR_MULTIPLE flag set). .. method:: GetSelections(self) Returns a list of selected items. .. note:: This method can be used only if :class:`CustomTreeCtrl` has the ``TR_MULTIPLE`` or ``TR_EXTENDED`` style set. :return: A Python list containing the selected items, all instances of :class:`GenericTreeItem`. .. method:: GetSeparatorColour(self, colour) Returns the pen colour for separator-type items. :return: An instance of :class:`wx.Colour` representing the separator pen colour. .. method:: GetSpacing(self) Returns the spacing between the start and the text, in pixels. .. method:: GetStateImageList(self) Returns the state image list associated with :class:`CustomTreeCtrl` (from which application-defined state images are taken). :return: An instance of :class:`wx.ImageList`. .. method:: HandleHyperLink(self, item) Handles the hyperlink items, sending the ``EVT_TREE_ITEM_HYPERLINK`` event. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: HasAGWFlag(self, flag) Returns ``True`` if :class:`CustomTreeCtrl` has the `flag` bit set. :param integer `flag`: any possible window style for :class:`CustomTreeCtrl`. .. seealso:: The :meth:`~CustomTreeCtrl.__init__` method for the `flag` parameter description. .. method:: HasButtons(self) Returns whether :class:`CustomTreeCtrl` has the ``TR_HAS_BUTTONS`` flag set. :return: ``True`` if :class:`CustomTreeCtrl` has the ``TR_HAS_BUTTONS`` flag set, ``False`` otherwise. .. method:: HasChildren(self, item) Returns whether an item has children or not. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: HideItem(self, item, hide=True) Hides/shows an item. :param `item`: an instance of :class:`GenericTreeItem`; :param `hide`: ``True`` to hide the item, ``False`` to show it. .. note:: A hidden item always reports that it is collapsed and disabled. .. method:: HideItemWindows(self, item) Hide all windows belonging to the item and its children. .. method:: HideWindows(self) Hides the windows associated to the items. Used internally. .. method:: HitTest(self, point, flags=0) Calculates which (if any) item is under the given point, returning the tree item at this point plus extra information flags. :param `point`: an instance of :class:`wx.Point`, a point to test for hits; :param integer `flags`: a bitlist of the following values: ================================== =============== ================================= HitTest Flags Hex Value Description ================================== =============== ================================= ``TREE_HITTEST_ABOVE`` 0x1 Above the client area ``TREE_HITTEST_BELOW`` 0x2 Below the client area ``TREE_HITTEST_NOWHERE`` 0x4 No item has been hit ``TREE_HITTEST_ONITEMBUTTON`` 0x8 On the button associated to an item ``TREE_HITTEST_ONITEMICON`` 0x10 On the icon associated to an item ``TREE_HITTEST_ONITEMINDENT`` 0x20 On the indent associated to an item ``TREE_HITTEST_ONITEMLABEL`` 0x40 On the label (string) associated to an item ``TREE_HITTEST_ONITEM`` 0x50 Anywhere on the item ``TREE_HITTEST_ONITEMRIGHT`` 0x80 On the right of the label associated to an item ``TREE_HITTEST_TOLEFT`` 0x200 On the left of the client area ``TREE_HITTEST_TORIGHT`` 0x400 On the right of the client area ``TREE_HITTEST_ONITEMUPPERPART`` 0x800 On the upper part (first half) of the item ``TREE_HITTEST_ONITEMLOWERPART`` 0x1000 On the lower part (second half) of the item ``TREE_HITTEST_ONITEMCHECKICON`` 0x2000 On the check/radio icon, if present ================================== =============== ================================= :return: A tuple with the first value being an instance of :class:`GenericTreeItem` or ``None`` if no item has been hit-tested, and as second value an integer parameter `flag`. .. note:: both the item (if any, ``None`` otherwise) and the `flags` are always returned as a tuple. .. method:: InsertItem(self, parentId, input, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None, separator=False, on_the_right=True) Inserts an item after the given previous. :return: An instance of :class:`GenericTreeItem` upon successful insertion. .. seealso:: :meth:`~CustomTreeCtrl.InsertItemByIndex` and :meth:`~CustomTreeCtrl.InsertItemByItem` for an explanation of the input parameters. .. seealso:: :meth:`~CustomTreeCtrl.DoInsertItem` for possible exceptions generated by this method. .. method:: InsertItemByIndex(self, parentId, idPrevious, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None, separator=False, on_the_right=True) Inserts an item after the given previous. :param `parentId`: an instance of :class:`GenericTreeItem` representing the item's parent; :param `idPrevious`: the index at which we should insert the new item; :param string `text`: the item text label; :param integer `ct_type`: the item type (see :meth:`~CustomTreeCtrl.SetItemType` for a list of valid item types); :param `wnd`: if not ``None``, a non-toplevel window to show next to the item, any subclass of :class:`wx.Window`; :param integer `image`: an index within the normal image list specifying the image to use for the item in unselected state; :param integer `selImage`: an index within the normal image list specifying the image to use for the item in selected state; if `image` > -1 and `selImage` is -1, the same image is used for both selected and unselected items; :param object `data`: associate the given Python object `data` with the item; :param bool `separator`: ``True`` if the item is a separator, ``False`` otherwise. :param bool `on_the_right`: ``True`` positions the window on the right of text, ``False`` on the left of text and overlapping the image. :return: An instance of :class:`GenericTreeItem` upon successful insertion. .. seealso:: :meth:`~CustomTreeCtrl.DoInsertItem` for possible exceptions generated by this method. .. method:: InsertItemByItem(self, parentId, idPrevious, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None, separator=False, on_the_right=True) Inserts an item after the given previous. :param `parentId`: an instance of :class:`GenericTreeItem` representing the item's parent; :param `idPrevious`: an instance of :class:`GenericTreeItem` representing the previous item; :param string `text`: the item text label; :param integer `ct_type`: the item type (see :meth:`~CustomTreeCtrl.SetItemType` for a list of valid item types); :param `wnd`: if not ``None``, a non-toplevel window to show next to the item, any subclass of :class:`wx.Window`; :param integer `image`: an index within the normal image list specifying the image to use for the item in unselected state; :param integer `selImage`: an index within the normal image list specifying the image to use for the item in selected state; if `image` > -1 and `selImage` is -1, the same image is used for both selected and unselected items; :param object `data`: associate the given Python object `data` with the item; :param bool `separator`: ``True`` if the item is a separator, ``False`` otherwise. :param bool `on_the_right`: ``True`` positions the window on the right of text, ``False`` on the left of text and overlapping the image. :return: An instance of :class:`GenericTreeItem` upon successful insertion. :raise: `Exception` if the previous item is not a sibling. .. seealso:: :meth:`~CustomTreeCtrl.DoInsertItem` for other possible exceptions generated by this method. .. method:: InsertSeparator(self, parentId, input) Inserts a separator item after the given previous. :return: An instance of :class:`GenericTreeItem` upon successful insertion. .. seealso:: :meth:`~CustomTreeCtrl.InsertItemByIndex` and :meth:`~CustomTreeCtrl.InsertItemByItem` for an explanation of the input parameters. .. seealso:: :meth:`~CustomTreeCtrl.DoInsertItem` for possible exceptions generated by this method. .. method:: IsBold(self, item) Returns whether the item font is bold or not. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item has bold text, ``False`` otherwise. .. method:: IsDescendantOf(self, parent, item) Checks if the given item is under another one in the tree hierarchy. :param `parent`: an instance of :class:`GenericTreeItem`, representing the possible parent of `item`; :param `item`: another instance of :class:`GenericTreeItem`. :return: ``True`` if `item` is a descendant of `parent`, ``False`` otherwise. .. method:: IsExpanded(self, item) Returns whether the item is expanded or not. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item is expanded, ``False`` if it is collapsed. .. method:: IsItalic(self, item) Returns whether the item font is italic or not. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item has italic text, ``False`` otherwise. .. method:: IsItem3State(self, item) Returns whether or not the checkbox item is a 3-state checkbox. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if this checkbox is a 3-state checkbox, ``False`` if it's a 2-state checkbox item. .. note:: This method is meaningful only for checkbox-like items. .. method:: IsItemChecked(self, item) Returns whether an item is checked or not. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item is in a 'checked' state, ``False`` otherwise. .. note:: This method is meaningful only for checkbox-like and radiobutton-like items. .. method:: IsItemEnabled(self, item) Returns whether an item is enabled or disabled. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: IsItemHyperText(self, item) Returns whether an item is hypertext or not. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item is hypertext-like, ``False`` otherwise. .. method:: IsItemSeparator(self, item) Returns whether an item is of separator type or not. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: IsSelected(self, item) Returns whether the item is selected or not. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item is selected, ``False`` otherwise. .. method:: IsVisible(self, item) Returns whether the item is visible or not (i.e., its hierarchy is expanded enough to show the item, and it has not been hidden). :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item is visible, ``False`` if it is hidden. .. method:: ItemHasChildren(self, item) Returns whether the item has children or not. :param `item`: an instance of :class:`GenericTreeItem`. :return: ``True`` if the item has children, ``False`` otherwise. .. method:: OnAcceptEdit(self, item, value) Called by :class:`TreeTextCtrl`, to accept the changes and to send the ``EVT_TREE_END_LABEL_EDIT`` event. :param `item`: an instance of :class:`GenericTreeItem`; :param string `value`: the new value of the item label. :return: ``True`` if the editing has not been vetoed, ``False`` otherwise. .. method:: OnCancelEdit(self, item) Called by :class:`TreeTextCtrl`, to cancel the changes and to send the ``EVT_TREE_END_LABEL_EDIT`` event. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: OnCompareItems(self, item1, item2) Returns whether 2 items have the same text. Override this function in the derived class to change the sort order of the items in the :class:`CustomTreeCtrl`. The function should return a negative, zero or positive value if the first item is less than, equal to or greater than the second one. :param `item1`: an instance of :class:`GenericTreeItem`; :param `item2`: another instance of :class:`GenericTreeItem`. :return: The return value is negative if `item1` < `item2`, zero if `item1` == `item2` and strictly positive if `item1` < `item2`. .. note:: The base class version compares items alphabetically. .. method:: OnDestroy(self, event) Handles the ``wx.EVT_WINDOW_DESTROY`` event for :class:`CustomTreeCtrl`. :param `event`: a :class:`wx.WindowDestroyEvent` event to be processed. .. method:: OnEditTimer(self) The timer for editing has expired. Start editing. .. method:: OnEraseBackground(self, event) Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`CustomTreeCtrl`. :param `event`: a :class:`EraseEvent` event to be processed. .. method:: OnGetToolTip(self, event) Process the tooltip event, to speed up event processing. Does not actually get a tooltip. :param `event`: a :class:`CommandTreeEvent` event to be processed. .. method:: OnInternalIdle(self) This method is normally only used internally, but sometimes an application may need it to implement functionality that should not be disabled by an application defining an `OnIdle` handler in a derived class. This method may be used to do delayed painting, for example, and most implementations call :meth:`wx.Window.UpdateWindowUI` in order to send update events to the window in idle time. .. method:: OnKeyDown(self, event) Handles the ``wx.EVT_KEY_DOWN`` event for :class:`CustomTreeCtrl`, sending a ``EVT_TREE_KEY_DOWN`` event. :param `event`: a :class:`KeyEvent` event to be processed. .. method:: OnKillFocus(self, event) Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`CustomTreeCtrl`. :param `event`: a :class:`FocusEvent` event to be processed. .. method:: OnMouse(self, event) Handles a bunch of ``wx.EVT_MOUSE_EVENTS`` events for :class:`CustomTreeCtrl`. :param `event`: a :class:`MouseEvent` event to be processed. .. method:: OnPaint(self, event) Handles the ``wx.EVT_PAINT`` event for :class:`CustomTreeCtrl`. :param `event`: a :class:`PaintEvent` event to be processed. .. method:: OnSetFocus(self, event) Handles the ``wx.EVT_SET_FOCUS`` event for :class:`CustomTreeCtrl`. :param `event`: a :class:`FocusEvent` event to be processed. .. method:: OnSize(self, event) Handles the ``wx.EVT_SIZE`` event for :class:`CustomTreeCtrl`. :param `event`: a :class:`wx.SizeEvent` event to be processed. .. method:: PaintItem(self, item, dc, level, align) Actually draws an item. :param `item`: an instance of :class:`GenericTreeItem`; :param `dc`: an instance of :class:`wx.DC`; :param integer `level`: the item level in the tree hierarchy; :param integer `align`: an integer specifying the alignment type: =============== ========================================= `align` Value Description =============== ========================================= 0 No horizontal alignment of windows (in items with windows). 1 Windows (in items with windows) are aligned at the same horizontal position. 2 Windows (in items with windows) are aligned at the rightmost edge of :class:`CustomTreeCtrl`. =============== ========================================= .. method:: PaintLevel(self, item, dc, level, y, align) Paint a level in the hierarchy of :class:`CustomTreeCtrl`. :param `item`: an instance of :class:`GenericTreeItem`; :param `dc`: an instance of :class:`wx.DC`; :param integer `level`: the item level in the tree hierarchy; :param integer `y`: the current vertical position in the :class:`ScrolledWindow`; :param integer `align`: an integer specifying the alignment type: =============== ========================================= `align` Value Description =============== ========================================= 0 No horizontal alignment of windows (in items with windows). 1 Windows (in items with windows) are aligned at the same horizontal position. 2 Windows (in items with windows) are aligned at the rightmost edge of :class:`CustomTreeCtrl`. =============== ========================================= .. method:: PrependItem(self, parent, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None, separator=False, on_the_right=True) Prepends an item as a first child of parent. :param `parent`: an instance of :class:`GenericTreeItem` representing the item's parent; :param string `text`: the item text label; :param integer `ct_type`: the item type (see :meth:`~CustomTreeCtrl.SetItemType` for a list of valid item types); :param `wnd`: if not ``None``, a non-toplevel window to show next to the item, any subclass of :class:`wx.Window` except top-level windows; :param integer `image`: an index within the normal image list specifying the image to use for the item in unselected state; :param integer `selImage`: an index within the normal image list specifying the image to use for the item in selected state; if `image` > -1 and `selImage` is -1, the same image is used for both selected and unselected items; :param object `data`: associate the given Python object `data` with the item; :param bool `separator`: ``True`` if the item is a separator, ``False`` otherwise. :param bool `on_the_right`: ``True`` positions the window on the right of text, ``False`` on the left of text and overlapping the image. :return: An instance of :class:`GenericTreeItem` upon successful insertion. .. seealso:: :meth:`~CustomTreeCtrl.DoInsertItem` for possible exceptions generated by this method. .. method:: PrependSeparator(self, parent) Prepends a separator item as a first child of parent. :param `parent`: an instance of :class:`GenericTreeItem` representing the item's parent. :return: An instance of :class:`GenericTreeItem` upon successful insertion. .. seealso:: :meth:`~CustomTreeCtrl.DoInsertItem` for possible exceptions generated by this method. .. method:: RecurseOnChildren(self, item, maxwidth, respect_expansion_state) Recurses over all the children of the spcified items, calculating their maximum width. :param `item`: an instance of :class:`GenericTreeItem`; :param integer `maxwidth`: the current maximum width for :class:`CustomTreeCtrl`, in pixels; :param bool `respect_expansion_state`: if ``True``, only the expanded items (and their children) will be measured. Otherwise all the items are expanded and their width measured. :return: A tuple containing the maximum width and item height, in pixels. .. method:: RefreshItemWithWindows(self, item=None) Refreshes the items with which a window is associated. :param `item`: an instance of :class:`GenericTreeItem`. If `item` is ``None``, then the recursive refresh starts from the root node. .. note:: This method is called only if the style ``TR_ALIGN_WINDOWS_RIGHT`` is used. .. method:: RefreshLine(self, item) Refreshes a damaged item line. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: RefreshSelected(self) Refreshes a damaged selected item line. .. method:: RefreshSelectedUnder(self, item) Refreshes the selected items under the given item. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: RefreshSubtree(self, item) Refreshes a damaged subtree of an item. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: ResetEditControl(self) Called by :class:`TreeTextCtrl` when it marks itself for deletion. .. method:: ScrollTo(self, item) Scrolls the specified item into view. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: SelectAll(self) Selects all the item in the tree. :raise: `Exception` if used without the ``TR_EXTENDED`` or ``TR_MULTIPLE`` style set. .. note:: This method can be used only if :class:`CustomTreeCtrl` has the ``TR_MULTIPLE`` or ``TR_EXTENDED`` style set. .. method:: SelectAllChildren(self, item) Selects all the children of the given item. :param `item`: an instance of :class:`GenericTreeItem`. :raise: `Exception` if used without the ``TR_EXTENDED`` or ``TR_MULTIPLE`` style set. .. note:: This method can be used only if :class:`CustomTreeCtrl` has the ``TR_MULTIPLE`` or ``TR_EXTENDED`` style set. .. method:: SelectItem(self, item, select=True) Selects/deselects an item. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `select`: ``True`` to select an item, ``False`` to deselect it. .. note:: If TR_MULTIPLE is set, this actually toggles selection when select=True. .. method:: SelectItemRange(self, item1, item2) Selects all the items between `item1` and `item2`. :param `item1`: an instance of :class:`GenericTreeItem`, representing the first item in the range to select; :param `item2`: an instance of :class:`GenericTreeItem`, representing the last item in the range to select. :raise: `Exception` if used without the ``TR_EXTENDED`` or ``TR_MULTIPLE`` style set. .. note:: This method can be used only if :class:`CustomTreeCtrl` has the ``TR_MULTIPLE`` or ``TR_EXTENDED`` style set. .. method:: SendDeleteEvent(self, item) Actually sends the ``EVT_TREE_DELETE_ITEM`` event. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: SetAGWWindowStyleFlag(self, agwStyle) Sets the :class:`CustomTreeCtrl` window style. :param integer `agwStyle`: the new :class:`CustomTreeCtrl` window style. .. seealso:: The :meth:`~CustomTreeCtrl.__init__` method for the `agwStyle` parameter description. .. method:: SetBackgroundColour(self, colour) Changes the background colour of :class:`CustomTreeCtrl`. :param `colour`: the colour to be used as the background colour, pass :class:`NullColour` to reset to the default colour. :return: ``False`` if the underlying :class:`ScrolledWindow` does not accept the new colour, ``True`` otherwise. .. note:: The background colour is usually painted by the default :class:`EraseEvent` event handler function under Windows and automatically under GTK. .. note:: Setting the background colour does not cause an immediate refresh, so you may wish to call :meth:`wx.Window.ClearBackground` or :meth:`wx.Window.Refresh` after calling this function. .. note:: Overridden from :class:`ScrolledWindow`. .. method:: SetBackgroundImage(self, image) Sets the :class:`CustomTreeCtrl` background image. :param `image`: if not ``None``, an instance of :class:`wx.Bitmap`. .. note:: At present, the background image can only be used in "tile" mode. .. todo:: Support background images also in stretch and centered modes. .. method:: SetBorderPen(self, pen) Sets the pen used to draw the selected item border. :param `pen`: an instance of :class:`wx.Pen`. .. note:: The border pen is not used if the Windows Vista selection style is applied. .. method:: SetButtonsImageList(self, imageList) Sets the buttons image list for :class:`CustomTreeCtrl` (from which application-defined button images are taken). :param `imageList`: an instance of :class:`wx.ImageList`. .. method:: SetConnectionPen(self, pen) Sets the pen used to draw the connecting lines between items. :param `pen`: an instance of :class:`wx.Pen`. .. method:: SetDisabledColour(self, colour) Sets the colour for items in a disabled state. :param `colour`: a valid :class:`wx.Colour` instance. .. method:: SetDragFullScreen(self, fullScreen=False) Sets whether a drag operation will be performed full screen or not. A full screen drag allows the user to drag outside of the tree to other controls. When the drag is finished the destination will have to be found manually in the ``EVT_TREE_END_DRAG`` handler with something like: example:: wnd = wx.FindWindowAtPoint(self.ClientToScreen(event.GetPoint())) :param bool `fullScreen`: ``False`` (default) to drag within tree only. .. method:: SetFirstGradientColour(self, colour=None) Sets the first gradient colour for gradient-style selections. :param `colour`: if not ``None``, a valid :class:`wx.Colour` instance. Otherwise, the colour is taken from the system value ``wx.SYS_COLOUR_HIGHLIGHT``. .. method:: SetFont(self, font) Sets the :class:`CustomTreeCtrl` font. :param `font`: a valid :class:`wx.Font` instance. .. note:: Overridden from :class:`ScrolledWindow`. .. method:: SetForegroundColour(self, colour) Changes the foreground colour of :class:`CustomTreeCtrl`. :param `colour`: the colour to be used as the foreground colour, pass :class:`NullColour` to reset to the default colour. :return: ``False`` if the underlying :class:`ScrolledWindow` does not accept the new colour, ``True`` otherwise. .. note:: Overridden from :class:`ScrolledWindow`. .. method:: SetGradientStyle(self, vertical=0) Sets the gradient style for gradient-style selections. :param integer `vertical`: ``0`` for horizontal gradient-style selections, ``1`` for vertical gradient-style selections. .. method:: SetHilightFocusColour(self, colour) Sets the colour used to highlight focused selected items. :param `colour`: a valid :class:`wx.Colour` instance. .. note:: This is applied only if gradient and Windows Vista selection styles are disabled. .. method:: SetHilightNonFocusColour(self, colour) Sets the colour used to highlight unfocused selected items. :param `colour`: a valid :class:`wx.Colour` instance. .. note:: This is applied only if gradient and Windows Vista selection styles are disabled. .. method:: SetHyperTextFont(self, font) Sets the font used to render hypertext items. :param `font`: a valid :class:`wx.Font` instance. .. note:: This method is meaningful only for hypertext-like items. .. method:: SetHyperTextNewColour(self, colour) Sets the colour used to render a non-visited hypertext item. :param `colour`: a valid :class:`wx.Colour` instance. .. note:: This method is meaningful only for hypertext-like items. .. method:: SetHyperTextVisitedColour(self, colour) Sets the colour used to render a visited hypertext item. :param `colour`: a valid :class:`wx.Colour` instance. .. note:: This method is meaningful only for hypertext-like items. .. method:: SetImageList(self, imageList) Sets the normal image list for :class:`CustomTreeCtrl`. :param `imageList`: an instance of :class:`wx.ImageList`. .. method:: SetImageListCheck(self, sizex, sizey, imglist=None) Sets the checkbox/radiobutton image list. :param integer `sizex`: the width of the bitmaps in the `imglist`, in pixels; :param integer `sizey`: the height of the bitmaps in the `imglist`, in pixels; :param `imglist`: an instance of :class:`wx.ImageList`. .. method:: SetIndent(self, indent) Sets the indentation for :class:`CustomTreeCtrl`. :param integer `indent`: an integer representing the indentation for the items in the tree. .. method:: SetItem3State(self, item, allow) Sets whether the item has a 3-state value checkbox assigned to it or not. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `allow`: ``True`` to set an item as a 3-state checkbox, ``False`` to set it to a 2-state checkbox. :return: ``True`` if the change was successful, ``False`` otherwise. .. note:: This method is meaningful only for checkbox-like items. .. method:: SetItem3StateValue(self, item, state) Sets the checkbox item to the given `state`. :param `item`: an instance of :class:`GenericTreeItem`; :param integer `state`: can be one of: ``wx.CHK_UNCHECKED`` (check is off), ``wx.CHK_CHECKED`` (check is on) or ``wx.CHK_UNDETERMINED`` (check is mixed). .. note:: This method raises an exception when the checkbox item is a 2-state checkbox and setting the state to ``wx.CHK_UNDETERMINED``. .. note:: This method is meaningful only for checkbox-like items. .. method:: SetItemBackgroundColour(self, item, colour) Sets the item background colour. :param `item`: an instance of :class:`GenericTreeItem`; :param `colour`: a valid :class:`wx.Colour` instance. .. method:: SetItemBold(self, item, bold=True) Sets the item font as bold/unbold. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `bold`: ``True`` to set the item font as bold, ``False`` otherwise. .. method:: SetItemDropHighlight(self, item, highlight=True) Gives the item the visual feedback for drag and drop operations. This is useful when something is dragged from outside the :class:`CustomTreeCtrl`. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `highlight`: ``True`` to highlight the dragged items, ``False`` otherwise. .. method:: SetItemFont(self, item, font) Sets the item font. :param `item`: an instance of :class:`GenericTreeItem`; :param `font`: a valid :class:`wx.Font` instance. .. method:: SetItemHasChildren(self, item, has=True) Forces the appearance/disappearance of the button next to the item. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `has`: ``True`` to have a button next to an item, ``False`` otherwise. .. method:: SetItemHyperText(self, item, hyper=True) Sets whether the item is hypertext or not. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `hyper`: ``True`` to have an item with hypertext behaviour, ``False`` otherwise. .. method:: SetItemImage(self, item, image, which=TreeItemIcon_Normal) Sets the item image, depending on the item state. :param `item`: an instance of :class:`GenericTreeItem`; :param integer `image`: an index within the normal image list specifying the image to use for the item in the state specified by the `which` parameter; :param integer `which`: the item state. .. seealso:: :meth:`~CustomTreeCtrl.GetItemImage` for an explanation of the `which` parameter. .. method:: SetItemItalic(self, item, italic=True) Sets the item font as italic/non-italic. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `italic`: ``True`` to set the item font as italic, ``False`` otherwise. .. method:: SetItemLeftImage(self, item, image) Sets the item leftmost image, i.e. the image associated to the item on the leftmost part of the :class:`CustomTreeCtrl` client area. :param `item`: an instance of :class:`GenericTreeItem`; :param integer `image`: an index within the left image list specifying the image to use for the item in the leftmost part of the client area. .. method:: SetItemText(self, item, text) Sets the item text. :param `item`: an instance of :class:`GenericTreeItem`; :param string `text`: the new item label. :raise: `Exception` if the input `item` is a separator. .. method:: SetItemTextColour(self, item, colour) Sets the item text colour or separator horizontal line colour. :param `item`: an instance of :class:`GenericTreeItem`; :param `colour`: a valid :class:`wx.Colour` instance. .. method:: SetItemType(self, item, ct_type) Sets the item type. :param `item`: an instance of :class:`GenericTreeItem`; :param integer `ct_type`: may be one of the following integers: =============== ========================================= `ct_type` Value Description =============== ========================================= 0 A normal item 1 A checkbox-like item 2 A radiobutton-type item =============== ========================================= .. note:: Regarding radiobutton-type items (with `ct_type` = 2), the following approach is used: - All peer-nodes that are radiobuttons will be mutually exclusive. In other words, only one of a set of radiobuttons that share a common parent can be checked at once. If a radiobutton node becomes checked, then all of its peer radiobuttons must be unchecked. - If a radiobutton node becomes unchecked, then all of its child nodes will become inactive. .. method:: SetItemVisited(self, item, visited=True) Sets whether an hypertext item was visited. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `visited`: ``True`` to mark an hypertext item as visited, ``False`` otherwise. .. note:: This method is meaningful only for hypertext-like items. .. method:: SetItemWindow(self, item, wnd, on_the_right=True) Sets the window for the given item. :param `item`: an instance of :class:`GenericTreeItem`; :param `wnd`: if not ``None``, a non-toplevel window to be displayed next to the item. :param bool `on_the_right`: ``True`` positions the window on the right of text, ``False`` on the left of text and overlapping the image. New in wxPython 4.0.4. :raise: `Exception` if the input `item` is a separator and `wnd` is not ``None``. .. method:: SetItemWindowEnabled(self, item, enable=True) Enables/disables the window associated to the item. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `enable`: ``True`` to enable the associated window, ``False`` to disable it. .. method:: SetLeftImageList(self, imageList) Sets the image list for :class:`CustomTreeCtrl` filled with images to be used on the leftmost part of the client area. Any item can have a leftmost image associated with it. :param `imageList`: an instance of :class:`wx.ImageList`. .. method:: SetPyData(self, item, data) Sets the data associated to an item. :param `item`: an instance of :class:`GenericTreeItem`; :param object `data`: can be any Python object. .. method:: SetSecondGradientColour(self, colour=None) Sets the second gradient colour for gradient-style selections. :param `colour`: if not ``None``, a valid :class:`wx.Colour` instance. Otherwise, the colour generated is a slightly darker version of the :class:`CustomTreeCtrl` background colour. .. method:: SetSeparatorColour(self, colour) Sets the pen colour for separator-type items. :param `colour`: a valid instance of :class:`wx.Colour`. .. method:: SetSpacing(self, spacing) Sets the spacing between items in :class:`CustomTreeCtrl`. :param integer `spacing`: an integer representing the spacing between items in the tree. .. method:: SetStateImageList(self, imageList) Sets the state image list for :class:`CustomTreeCtrl` (from which application-defined state images are taken). :param `imageList`: an instance of :class:`wx.ImageList`. .. method:: ShouldInheritColours(self) Return ``True`` from here to allow the colours of this window to be changed by `InheritAttributes`, returning ``False`` forbids inheriting them from the parent window. The base class version returns ``False``, but this method is overridden in :class:`wx.Control` where it returns ``True``. :class:`CustomTreeCtrl` does not inherit colours from anyone. .. method:: SortChildren(self, item) Sorts the children of the given item using the :meth:`~CustomTreeCtrl.OnCompareItems` method of :class:`CustomTreeCtrl`. :param `item`: an instance of :class:`GenericTreeItem`. .. note:: You should override the :meth:`~CustomTreeCtrl.OnCompareItems` method in your derived class to change the sort order (the default is ascending case-sensitive alphabetical order). .. method:: TagAllChildrenUntilLast(self, crt_item, last_item, select) Used internally. .. method:: TagNextChildren(self, crt_item, last_item, select) Used internally. .. method:: Thaw(self) Thaw :class:`CustomTreeCtrl`. Reenables window updating after a previous call to :meth:`~Freeze`. To really thaw the control, it must be called exactly the same number of times as :meth:`~Freeze`. :raise: `Exception` if :meth:`~Thaw` has been called without an un-matching :meth:`~Freeze`. .. method:: TileBackground(self, dc) Tiles the background image to fill all the available area. :param `dc`: an instance of :class:`wx.DC`. .. todo:: Support background images also in stretch and centered modes. .. method:: Toggle(self, item) Toggles the item state (collapsed/expanded). :param `item`: an instance of :class:`GenericTreeItem`. .. method:: ToggleItemSelection(self, item) Toggles the item selection. :param `item`: an instance of :class:`GenericTreeItem`. .. method:: UnCheckRadioParent(self, item, checked=False) Used internally to handle radio node parent correctly. :param `item`: an instance of :class:`GenericTreeItem`; :param bool `checked`: ``True`` to check an item, ``False`` to uncheck it. .. method:: Unselect(self) Unselects the current selection. .. method:: UnselectAll(self) Unselect all the items. .. method:: UnselectAllChildren(self, item) Unselects all the children of the given item. :param `item`: an instance of :class:`GenericTreeItem`.