Phoenix Logo

phoenix_title wx.lib.agw.hypertreelist.TreeListMainWindow

This class represents the main window (and thus the main column) in HyperTreeList.

Note

This is a subclass of CustomTreeCtrl.


class_hierarchy Class Hierarchy

Inheritance diagram for class TreeListMainWindow:

method_summary Methods Summary

__init__ Default class constructor.
AddRoot Adds a root item to the TreeListMainWindow.
AdjustMyScrollbars Internal method used to adjust the ScrolledWindow scrollbars.
CalculateLevel Calculates the level of an item inside the tree hierarchy.
CalculatePositions Recalculates all the items positions.
CalculateSize Calculates overall position and size of an item.
ChildrenClosing We are about to destroy the item’s children.
Delete Deletes an item.
DeleteAllItems Delete all items in the TreeListMainWindow.
DeleteRoot Removes the tree root item (and subsequently all the items in
DoInsertItem Actually inserts an item in the tree.
EditLabel Starts editing an item label.
EnableItem Enables/disables an item.
GetBestColumnWidth Returns the best column’s width based on the items width in this column.
GetColumnCount Returns the total number of columns.
GetCurrentItem Returns the current item.
GetFirstExpandedItem Returns the first item which is in the expanded state.
GetFirstVisibleItem Returns the first visible item.
GetItemImage Returns the item image.
GetItemText Returns the item text label.
GetItemWidth Returns the item width.
GetItemWindow Returns the window associated with an item.
GetItemWindowEnabled Returns whether the window associated with an item is enabled or not.
GetMainColumn Returns the HyperTreeList main column (i.e. the position of the underlying
GetNextExpanded Returns the next expanded item after the input one.
GetPrevChild Returns the previous child of an item.
GetPrevExpanded Returns the previous expanded item before the input one.
GetPrevVisible Returns the previous visible item before the input one.
HideItem Hides/shows an item.
HideWindows Hides the windows associated to the items. Used internally.
HitTest Calculates which (if any) item is under the given point, returning the tree item
IsItemEnabled Returns whether an item is enabled or disabled.
IsItemVisible Returns whether the item is visible or not.
IsVirtual Returns True if TreeListMainWindow has the TR_VIRTUAL flag set.
OnAcceptEdit Called by EditTextCtrl, to accept the changes and to send the
OnCancelEdit Called by EditCtrl, to cancel the changes and to send the
OnEditTimer The timer for editing has expired. Start editing.
OnEraseBackground Handles the wx.EVT_ERASE_BACKGROUND event for TreeListMainWindow.
OnMouse Handles the wx.EVT_MOUSE_EVENTS event for TreeListMainWindow.
OnPaint Handles the wx.EVT_PAINT event for TreeListMainWindow.
OnScroll Handles the wx.EVT_SCROLLWIN event for TreeListMainWindow.
PaintItem Actually draws an item.
PaintLevel Paint a level in the hierarchy of TreeListMainWindow.
ScrollTo Scrolls the specified item into view.
SetBuffered Sets/unsets the double buffering for the main window.
SetDragItem Sets the specified item as member of a current drag and drop operation.
SetItemImage Sets the item image for a particular item state.
SetItemText Sets the item text label.
SetItemWindow Sets the window associated to an item.
SetItemWindowEnabled Sets whether the window associated with an item is enabled or not.
SetMainColumn Sets the HyperTreeList main column (i.e. the position of the underlying

api Class API



class TreeListMainWindow(CustomTreeCtrl)

This class represents the main window (and thus the main column) in HyperTreeList.

Note

This is a subclass of CustomTreeCtrl.


Methods



__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, agwStyle=wx.TR_DEFAULT_STYLE, validator=wx.DefaultValidator, name="wxtreelistmainwindow")

Default class constructor.

Parameters:
  • parent – parent window. Must not be None;
  • id – window identifier. A value of -1 indicates a default value;
  • pos – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;
  • size – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;
  • style – the underlying ScrolledWindow style;
  • agwStyle – the AGW-specific TreeListMainWindow window style. This can be a combination of the following bits:
    Window Styles Hex Value Description
    TR_NO_BUTTONS 0x0 For convenience to document that no buttons are to be drawn.
    TR_SINGLE 0x0 For convenience to document that only one item may be selected at a time. Selecting another item causes the current selection, if any, to be deselected. This is the default.
    TR_HAS_BUTTONS 0x1 Use this style to show + and - buttons to the left of parent items.
    TR_NO_LINES 0x4 Use this style to hide vertical level connectors.
    TR_LINES_AT_ROOT 0x8 Use this style to show lines between root nodes. Only applicable if TR_HIDE_ROOT is set and TR_NO_LINES is not set.
    TR_DEFAULT_STYLE 0x9 The set of flags that are closest to the defaults for the native control for a particular toolkit.
    TR_TWIST_BUTTONS 0x10 Use old Mac-twist style buttons.
    TR_MULTIPLE 0x20 Use this style to allow a range of items to be selected. If a second range is selected, the current range, if any, is deselected.
    TR_EXTENDED 0x40 Use this style to allow disjoint items to be selected. (Only partially implemented; may not work in all cases).
    TR_HAS_VARIABLE_ROW_HEIGHT 0x80 Use this style to cause row heights to be just big enough to fit the content. If not set, all rows use the largest row height. The default is that this flag is unset.
    TR_EDIT_LABELS 0x200 Use this style if you wish the user to be able to edit labels in the tree control.
    TR_ROW_LINES 0x400 Use this style to draw a contrasting border between displayed rows.
    TR_HIDE_ROOT 0x800 Use this style to suppress the display of the root node, effectively causing the first-level nodes to appear as a series of root nodes.
    TR_FULL_ROW_HIGHLIGHT 0x2000 Use this style to have the background colour and the selection highlight extend over the entire horizontal row of the tree control window.
    TR_AUTO_CHECK_CHILD 0x4000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are checked/unchecked as well.
    TR_AUTO_TOGGLE_CHILD 0x8000 Only meaningful for checkbox-type items: when a parent item is checked/unchecked its children are toggled accordingly.
    TR_AUTO_CHECK_PARENT 0x10000 Only meaningful for checkbox-type items: when a child item is checked/unchecked its parent item is checked/unchecked as well.
    TR_ALIGN_WINDOWS 0x20000 Flag used to align windows (in items with windows) at the same horizontal position.
    TR_NO_HEADER 0x40000 Use this style to hide the columns header.
    TR_ELLIPSIZE_LONG_ITEMS 0x80000 Flag used to ellipsize long items when the horizontal space for CustomTreeCtrl is low.
    TR_VIRTUAL 0x100000 HyperTreeList will have virtual behaviour.
  • validator – window validator;
  • name – window name.


AddRoot(self, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None)

Adds a root item to the TreeListMainWindow.

Parameters:
  • text – the item text label;
  • ct_type – the item type (see CustomTreeCtrl.SetItemType() for a list of valid item types);
  • wnd – if not None, a non-toplevel window to show next to the item;
  • image – an index within the normal image list specifying the image to use for the item in unselected state;
  • 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;
  • data – associate the given Python object data with the item.

Warning

Only one root is allowed to exist in any given instance of TreeListMainWindow.



AdjustMyScrollbars(self)

Internal method used to adjust the ScrolledWindow scrollbars.



CalculateLevel(self, item, dc, level, y, x_colstart)

Calculates the level of an item inside the tree hierarchy.

Parameters:
  • item – an instance of TreeListItem;
  • dc – an instance of wx.DC;
  • level – the item level in the tree hierarchy;
  • y – the current vertical position inside the ScrolledWindow;
  • x_colstart – the x coordinate at which the item’s column starts.


CalculatePositions(self)

Recalculates all the items positions.



CalculateSize(self, item, dc)

Calculates overall position and size of an item.

Parameters:


ChildrenClosing(self, item)

We are about to destroy the item’s children.

Parameters:item – an instance of TreeListItem.


Delete(self, item)

Deletes an item.

Parameters:item – an instance of TreeListItem.


DeleteAllItems(self)

Delete all items in the TreeListMainWindow.



DeleteRoot(self)

Removes the tree root item (and subsequently all the items in TreeListMainWindow.



DoInsertItem(self, parent, previous, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None, separator=False)

Actually inserts an item in the tree.

Parameters:
  • parentId – an instance of TreeListItem representing the item’s parent;
  • previous – the index at which we should insert the item;
  • text – the item text label;
  • ct_type – the item type (see CustomTreeCtrl.SetItemType() for a list of valid item types);
  • wnd – if not None, a non-toplevel window to show next to the item;
  • image – an index within the normal image list specifying the image to use for the item in unselected state;
  • 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;
  • data – associate the given Python object data with the item.
  • separator – unused at the moment, this parameter is present to comply with CustomTreeCtrl.DoInsertItem() changed API.


EditLabel(self, item, column=None)

Starts editing an item label.

Parameters:
  • item – an instance of TreeListItem;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used.


EnableItem(self, item, enable=True, torefresh=True)

Enables/disables an item.

Parameters:
  • item – an instance of TreeListItem;
  • enableTrue to enable the item, False otherwise;
  • torefresh – whether to redraw the item or not.


GetBestColumnWidth(self, column, parent=None)

Returns the best column’s width based on the items width in this column.

Parameters:
  • column – an integer specifying the column index;
  • parent – an instance of TreeListItem.


GetColumnCount(self)

Returns the total number of columns.



GetCurrentItem(self)

Returns the current item.



GetFirstExpandedItem(self)

Returns the first item which is in the expanded state.



GetFirstVisibleItem(self)

Returns the first visible item.



GetItemImage(self, item, column=None, which=wx.TreeItemIcon_Normal)

Returns the item image.

Parameters:
  • item – an instance of TreeListItem;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used;
  • 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)


GetItemText(self, item, column=None)

Returns the item text label.

Parameters:
  • item – an instance of TreeListItem;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used.


GetItemWidth(self, item, column)

Returns the item width.

Parameters:
  • item – an instance of TreeListItem;
  • column – an integer specifying the column index.


GetItemWindow(self, item, column=None)

Returns the window associated with an item.

Parameters:
  • item – an instance of TreeListItem;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used.


GetItemWindowEnabled(self, item, column=None)

Returns whether the window associated with an item is enabled or not.

Parameters:
  • item – an instance of TreeListItem;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used.


GetMainColumn(self)

Returns the HyperTreeList main column (i.e. the position of the underlying CustomTreeCtrl.



GetNextExpanded(self, item)

Returns the next expanded item after the input one.

Parameters:item – an instance of TreeListItem.


GetPrevChild(self, item, cookie)

Returns the previous child of an item.

Parameters:
  • item – an instance of TreeListItem;
  • 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).

Note

This method returns None if there are no further siblings.



GetPrevExpanded(self, item)

Returns the previous expanded item before the input one.

Parameters:item – an instance of TreeListItem.


GetPrevVisible(self, item)

Returns the previous visible item before the input one.

Parameters:item – an instance of TreeListItem.


HideItem(self, item, hide=True)

Hides/shows an item.

Parameters:
  • item – an instance of TreeListItem;
  • hideTrue to hide the item, False to show it.


HideWindows(self)

Hides the windows associated to the items. Used internally.



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 plus the item’s column.

Parameters:
  • point – an instance of wx.Point, a point to test for hits;
  • 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
Returns:

the item (if any, None otherwise), the flags and the column are always returned as a tuple.



IsItemEnabled(self, item)

Returns whether an item is enabled or disabled.

Parameters:item – an instance of TreeListItem.


IsItemVisible(self, item)

Returns whether the item is visible or not.

Parameters:item – an instance of TreeListItem;


IsVirtual(self)

Returns True if TreeListMainWindow has the TR_VIRTUAL flag set.



OnAcceptEdit(self, value)

Called by EditTextCtrl, to accept the changes and to send the EVT_TREE_END_LABEL_EDIT event.

Parameters:value – the new value of the item label.


OnCancelEdit(self)

Called by EditCtrl, to cancel the changes and to send the EVT_TREE_END_LABEL_EDIT event.



OnEditTimer(self)

The timer for editing has expired. Start editing.



OnEraseBackground(self, event)

Handles the wx.EVT_ERASE_BACKGROUND event for TreeListMainWindow.

Parameters:event – a EraseEvent event to be processed.


OnMouse(self, event)

Handles the wx.EVT_MOUSE_EVENTS event for TreeListMainWindow.

Parameters:event – a MouseEvent event to be processed.


OnPaint(self, event)

Handles the wx.EVT_PAINT event for TreeListMainWindow.

Parameters:event – a PaintEvent event to be processed.


OnScroll(self, event)

Handles the wx.EVT_SCROLLWIN event for TreeListMainWindow.

Parameters:event – a ScrollEvent event to be processed.


PaintItem(self, item, dc)

Actually draws an item.

Parameters:


PaintLevel(self, item, dc, level, y, x_maincol)

Paint a level in the hierarchy of TreeListMainWindow.

Parameters:
  • item – an instance of TreeListItem;
  • dc – an instance of wx.DC;
  • level – the item level in the tree hierarchy;
  • y – the current vertical position in the ScrolledWindow;
  • x_maincol – the horizontal position of the main column.


ScrollTo(self, item)

Scrolls the specified item into view.

Parameters:item – an instance of TreeListItem.


SetBuffered(self, buffered)

Sets/unsets the double buffering for the main window.

Parameters:bufferedTrue to use double-buffering, False otherwise.

Note

Currently we are using double-buffering only on Windows XP.



SetDragItem(self, item)

Sets the specified item as member of a current drag and drop operation.

Parameters:item – an instance of TreeListItem.


SetItemImage(self, item, image, column=None, which=wx.TreeItemIcon_Normal)

Sets the item image for a particular item state.

Parameters:
  • item – an instance of TreeListItem;
  • image – an index within the normal image list specifying the image to use;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used;
  • which – the item state.

See also

GetItemImage for a list of valid item states.



SetItemText(self, item, text, column=None)

Sets the item text label.

Parameters:
  • item – an instance of TreeListItem;
  • text – a string specifying the new item label;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used.


SetItemWindow(self, item, window, column=None)

Sets the window associated to an item.

Parameters:
  • item – an instance of TreeListItem;
  • wnd – a non-toplevel window to be displayed next to the item;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used.

Note

The window parent should not be the HyperTreeList itself, but actually an instance of TreeListMainWindow. The current solution here is to reparent the window to this class.



SetItemWindowEnabled(self, item, enable=True, column=None)

Sets whether the window associated with an item is enabled or not.

Parameters:
  • item – an instance of TreeListItem;
  • enableTrue to enable the associated window, False to disable it;
  • column – if not None, an integer specifying the column index. If it is None, the main column index is used.


SetMainColumn(self, column)

Sets the HyperTreeList main column (i.e. the position of the underlying CustomTreeCtrl.

Parameters:column – if not None, an integer specifying the column index. If it is None, the main column index is used.