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¶
Known Superclasses¶
wx.lib.agw.customtreectrl.CustomTreeCtrl
Methods Summary¶
Default class constructor. |
|
Adds a root item to the |
|
Internal method used to adjust the |
|
Calculates the level of an item inside the tree hierarchy. |
|
Recalculates all the items positions. |
|
Calculates overall position and size of an item. |
|
We are about to destroy the item’s children. |
|
Deletes an item. |
|
Delete all items in the |
|
Deletes the window in the column associated to an item (if any). |
|
Removes the tree root item (and subsequently all the items in |
|
Actually inserts an item in the tree. |
|
Starts editing an item label. |
|
Enables/disables an item. |
|
Returns the best column’s width based on the items width in this column. |
|
Returns the total number of columns. |
|
Returns the current item. |
|
Returns the first item which is in the expanded state. |
|
Returns the first visible item. |
|
Returns the column background colour of the item |
|
Returns the item image. |
|
Returns the item text label. |
|
Returns the item width. |
|
Returns the window associated with an item. |
|
Returns whether the window associated with an item is enabled or not. |
|
Returns the |
|
Returns the next expanded item after the input one. |
|
Returns the previous child of an item. |
|
Returns the previous expanded item before the input one. |
|
Returns the previous visible item before the input one. |
|
Hides all windows belonging to given item and its children. |
|
Scans all item windows in the tree and hides those whose items |
|
Calculates which (if any) item is under the given point, returning the tree item |
|
Returns whether an item is enabled or disabled. |
|
Returns whether the item is visible or not. |
|
Returns |
|
Called by |
|
Called by |
|
The timer for editing has expired. Start editing. |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Actually draws an item. |
|
Paint a level in the hierarchy of |
|
Scrolls the specified item into view. |
|
Sets/unsets the double buffering for the main window. |
|
Sets the specified item as member of a current drag and drop operation. |
|
Sets the column background colour of the item |
|
Sets the item image for a particular item state. |
|
Sets the item text label. |
|
Sets the window associated to an item. |
|
Sets whether the window associated with an item is enabled or not. |
|
Sets the |
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 – can be a combination of various bits. See
hypertreelist
for a full list of flags.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:
item – an instance of
TreeListItem
;dc – an instance of
wx.DC
.
- 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
.
- DeleteItemWindow(self, item, column=None)¶
Deletes the window in the column associated to an item (if any).
- Parameters:
item – an instance of
GenericTreeItem
.column – if not
None
, an integer specifying the column index. If it isNone
, the main column index is used.
- 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, \*ignored_args)¶
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.
ignored_args – 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 isNone
, the main column index is used.
- EnableItem(self, item, enable=True, torefresh=True)¶
Enables/disables an item.
- Parameters:
item – an instance of
TreeListItem
;enable –
True
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.
This is the same as
GetSelection
.
- GetFirstExpandedItem(self)¶
Returns the first item which is in the expanded state.
- GetFirstVisibleItem(self)¶
Returns the first visible item.
- GetItemBackgroundColour(self, item, column=0)¶
Returns the column background colour of the item
- Parameters:
item – an instance of
TreeListItem
:param integer column
- 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 isNone
, 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 isNone
, 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 isNone
, 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 isNone
, the main column index is used.
- GetMainColumn(self)¶
Returns the
HyperTreeList
main column (i.e. the position of the underlyingCustomTreeCtrl
.
- 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
.
- HideItemWindows(self, item)¶
Hides all windows belonging to given item and its children.
- HideWindows(self)¶
Scans all item windows in the tree and hides those whose items they belong to are not currently visible. 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
;
Note
This method is renamed from
IsVisible
- IsVirtual(self)¶
Returns
True
ifTreeListMainWindow
has theTR_VIRTUAL
flag set.
- OnAcceptEdit(self, value)¶
Called by
EditTextCtrl
, to accept the changes and to send theEVT_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 theEVT_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 forTreeListMainWindow
.- Parameters:
event – a
EraseEvent
event to be processed.
- OnMouse(self, event)¶
Handles the
wx.EVT_MOUSE_EVENTS
event forTreeListMainWindow
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnPaint(self, event)¶
Handles the
wx.EVT_PAINT
event forTreeListMainWindow
.- Parameters:
event – a
PaintEvent
event to be processed.
- OnScroll(self, event)¶
Handles the
wx.EVT_SCROLLWIN
event forTreeListMainWindow
.- Parameters:
event – a
ScrollEvent
event to be processed.
- PaintItem(self, item, dc)¶
Actually draws an item.
- Parameters:
item – an instance of
TreeListItem
;dc – an instance of
wx.DC
.
- 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:
buffered –
True
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
.
- SetItemBackgroundColour(self, item, colour, column=0)¶
Sets the column background colour of the item
- Parameters:
item – an instance of
TreeListItem
colour – a valid
wx.Colour
instance.
:param integer column
- 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 isNone
, 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 isNone
, 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 isNone
, the main column index is used.
Note
The window being added should have its parent set to the
TreeListMainWindow
which can be obtained withGetHeaderWindow
. If this is not the case the window will be re-parented which may cause some flicker.
- 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
;enable –
True
to enable the associated window,False
to disable it;column – if not
None
, an integer specifying the column index. If it isNone
, the main column index is used.
- SetMainColumn(self, column)¶
Sets the
HyperTreeList
main column (i.e. the position of the underlyingCustomTreeCtrl
.- Parameters:
column – if not
None
, an integer specifying the column index. If it isNone
, the main column index is used.