Tree (hwx.gui)

Hierarchical list of items.

Inherits:

Properties

Public Methods

add (self, parent=None, text=None, icon=None, **kwds)

addColumn (self, label, width=-1)

clear (self)

collapseAll (self)

enableEdit (self, col=None, edit=True)

ensureItemVisible (self, item)

expandAll (self, expanded=True)

get (self)

getChildren (self, parent=None)

getSelected (self)

remove (self, item)

removeColumn (self, indices)

setSelected (self, items, selected=True, clear=True)

Property Details

property header

Column labels of the tree.

property numCols

The number of columns in the tree.

property selectionMode

The selection mode. Valid choices are:

  • “single”

  • “extended”

  • “multi”

  • “contiguous”

  • “none”

Method Details

add(self, parent=None, text=None, icon=None, **kwds)

Adds a TreeItem to the Tree.

param parent

A TreeItem to define hierarchy.

type parent

TreeItem

param text

Text or List of text that gets displayed in column.

type text

str|list[str]

param icon

Absolute path of the icon or a list of icons.

type icon

str|list[str]

returns

the added TreeItem.

rtype

TreeItem

addColumn(self, label, width=- 1)

Adds one or more columns to the tree, width pixes wide.

All columns apart from the first one are inserted to the right of the existing ones. If width is negative, the new column’s width is set to maximum.

param label

Name of the column.

type label

str|list[str]

param width

How wide each column is in pixels.

type width

int|list[int]

returns

The indices of the new columns.

rtype

list[int]

clear(self)

Removes all items from the tree.

collapseAll(self)

Collapses all items.

enableEdit(self, col=None, edit=True)

Makes all tree items or specific tree column to be editable.

param col

Column index needs to be make editable.

type col

int

param edit

If True, column is editable else not.

type edit

bool

ensureItemVisible(self, item)

Scrolls view so this item is visible.

param item

TreeItem to make visible.

type item

TreeItem

expandAll(self, expanded=True)

Expands (or collapses) all items.

param expanded

Determines whether to expand or not.

type expanded

bool

get(self)

Returns the current selected item.

getChildren(self, parent=None)

Overloaded Widget method for ‘children’ property.

getSelected(self)

Returns a list of the selected items.

remove(self, item)

Removes the specified item from the tree.

param item

Item to be removed.

type item

TreeItem

removeColumn(self, indices)

Removes columns based on their initial indices.

param indices

type indices

int|list[int]

setSelected(self, items, selected=True, clear=True)

Selects the specified items.

param items

list of TreeItems to be selected.

type items

list[TreeItem]

param selected

Determines if items will be selected or not.

type selected

bool

param clear

Determines if al previously selected items will be cleared or not.

type clear

bool