The Tree class inherits QTreeView Qt class.
Widget's input value
The input value of the Tree widget is an XML string in the form :
<tree> <header> <column>Label</column> <column>Label</column> ... </header> <row> <column>Value</column> <column>Value</column> ... </row> <row> <column>Value</column> <column>Value</column> ... <row> <column>Value</column> <column>Value</column> ... </row> <row> <column>Value</column> <column>Value</column> ... </row> ... </row> ... </tree>
Warning | |
---|---|
Unlike the example, the XML input value must not contain spaces between tags. |
The row tag can contain other rows which will be the row's children.
The following attributes can be specified in the different tags, see Table 4.3, “Tree widget XML attributes” to know where you can put each attribute.
This table defines in which tag attributes can be specified :
Attribute | <tree> tag | <header> tag | header's <column> tag | <row> tag | row's <column> tag |
---|---|---|---|---|---|
icon | X | X | X | X | X |
color | X | X | X | X | X |
bg | X | X | X | X | X |
font | X | X | X | X | X |
size | X | X | X | X | X |
decoration | X | X | X | X | X |
txt_color | X | X | X | X | X |
align | X | X | X | X | X |
ro | X | X | X | ||
id | X | X | X | ||
data | X | ||||
width | X | ||||
height | X | X | X | ||
tooltip | X | ||||
whatsthis | X | ||||
disabled | X | ||||
checked | X | X | X |
Table 4.3. Tree widget XML attributes
Widget's attributes
Widget's functions
Widget's signals
Widget's output value
The output value of a Tree widget depends on two attributes : verbose and return.
If return is dict, the output value is a bi-dimensional dict where each item's value can be accessed like this : output_value[row_id][column_id]. item's value is a dict in the form : {'column':INDEX, 'selected':BOOL, 'value':VALUE, 'checked':BOOL}. the checked key is available only for checkable items. The row's index is available at output_value[row_id]['__row__'] and the row's embedded data is available at output_value[row_id]['__data__']. Child rows are available via output_value[row_id]['__childs__'].
If return is list, the output value is a list of rows values. Each row's value is a dict in the form : {'id':ID, 'row':INDEX, 'columns':COLUMNS, 'data':DATA, 'childs':CHILDS} where COLUMNS is a list of items values and CHILDS a list of child rows. All those elements follows the screen order.
If verbose is True all rows are returned otherwise only selected rows are returned.