TreeWidgetItem

class cgp_generic_utils.qt.TreeWidgetItem(parent=None)

Bases: PySide2.QtWidgets.QTreeWidgetItem

QTreeWidgetItem with custom functionalities

addWidget(widget, index)

add the specified widget to the specified column of the QTreeWidgetItem

Parameters:
  • widget (PySide2.QtWidgets.QWidget) – widget to add the the QTreeWidgetItem
  • index (int) – index of the column where to add the widget
childrenItems(recursive=False)

get the children items parented to the QTreeWidgetItem

Parameters:recursive (bool) – defines whether or not the command will get the children items recursively through hierarchy
Returns:list of children
Return type:list[PySide2.QtWidgets.QTreeWidgetItem, cgp_generic_utils.qt.TreeWidgetItem]
setBackgrounds(indexes, color=None, pattern='solid')

set background colors of the columns of the specified indexes using the specified color and pattern

Parameters:
  • indexes (list[int]) – list of the column indexes use to set the backgrounds
  • color (list[int, float]) – color to set - [R, V, B, A] - [0.8, 0.8, 0.8, 1] is default
  • pattern (str) – pattern of the backgrounds
setFonts(indexes, size=9, styles=None)

set fonts of the columns of the specified indexes using the specified size and styles

Parameters:
  • indexes (list[int]) – list of the column indexes use to set the fonts
  • size (int) – size of the font
  • styles – styles of the font - [bold - italic - underline]
Type:

list[cgp_generic_utils.constants.TypoStyle]

setForegrounds(indexes, color=None, pattern='solid')

set foreground colors of the columns of the specified indexes using the specified color and pattern

Parameters:
  • indexes (list[int]) – list of the column indexes use to set the foregrounds
  • color (list[int, float]) – color to set - [R, V, B, A] - [0.8, 0.8, 0.8, 1] is default
  • pattern (str) – pattern of the foregrounds
setIcons(indexes, icon)

set the icon of the specified column of the custom QTreeWidgetItem

Parameters:
  • indexes (list) – index of the column to set the icon to
  • icon (str) – name of the icon to set
setSelectable(isSelectable)

set the status flags of the item

Parameters:isSelectable (bool) – defines whether or not the item is selectable
setTexts(texts)

set texts in the specified column using the specified texts

Parameters:texts (dict[int: str]) – dictionary holding column indexes and texts to set - {0: ‘text1’, 2:’text2’ …}