Treeform

class Treeform[source]

Bases: QTreeWidget

Class for displaying tree-like data. Treeform is an abstract class that could be placed in either the viewport or the sidedock.

Parameters:
treecompas.datastructures.Tree

The tree to be displayed. An typical example is the scene object tree: compas_viewer.viewer.Viewer._tree.

columnsdict[str, callable]

A dictionary of column names and their corresponding attributes. Example: {"Name": (lambda o: o.name), "Object": (lambda o: o)}

show_headersbool, optional

Show the header of the tree. Defaults to True.

stretchint, optional

Stretch factor of the tree in the grid layout. Defaults to 2.

backgroundsdict[str, callable], optional

A dictionary of column names and their corresponding color. Example: {"Object-Color": (lambda o: o.surfacecolor)}

Attributes:
treecompas.datastructures.Tree

The tree to be displayed.

See also

compas.datastructures.Tree
compas.datastructures.tree.TreeNode
compas_viewer.layout.SidedockLayout

References

PySide6/QtWidgets/QTreeWidget

Examples

from compas_viewer import Viewer

viewer = Viewer()

for i in range(10):
    for j in range(10):
        sp = viewer.scene.add(Sphere(0.1, Frame([i, j, 0], [1, 0, 0], [0, 1, 0])), name=f"Sphere_{i}_{j}")

viewer.layout.sidedock.add_element(Treeform(viewer._tree, {"Name": (lambda o: o.object.name), "Object": (lambda o: o.object)}))

viewer.show()

Methods

on_item_selection_changed

tree_from_dict

update

update_from_dict

Inherited Methods

acceptDrops

accessibleDescription

accessibleName

actionEvent

actions

activateWindow

addAction

addActions

addScrollBarWidget

addTopLevelItem

addTopLevelItems

adjustSize

allColumnsShowFocus

alternatingRowColors

autoExpandDelay

autoFillBackground

autoScrollMargin

backgroundRole

backingStore

baseSize

blockSignals

changeEvent

childAt

childEvent

children

childrenRect

childrenRegion

clear

clearFocus

clearMask

clearSelection

close

closeEditor

closeEvent

closePersistentEditor

collapse

collapseAll

collapseItem

colorCount

columnAt

columnCount

columnCountChanged

columnMoved

columnResized

columnViewportPosition

columnWidth

commitData

connect

connectNotify

contentsMargins

contentsRect

contextMenuEvent

contextMenuPolicy

cornerWidget

create

createWinId

createWindowContainer

currentChanged

currentColumn

currentIndex

currentItem

cursor

customEvent

dataChanged

defaultDropAction

deleteLater

depth

destroy

devType

devicePixelRatio

devicePixelRatioF

devicePixelRatioFScale

dirtyRegionOffset

disconnect

disconnectNotify

doAutoScroll

doItemsLayout

dragDropMode

dragDropOverwriteMode

dragEnabled

dragEnterEvent

dragLeaveEvent

dragMoveEvent

drawBranches

drawFrame

drawRow

drawTree

dropEvent

dropIndicatorPosition

dropMimeData

dumpObjectInfo

dumpObjectTree

dynamicPropertyNames

edit

editItem

editTriggers

editorDestroyed

effectiveWinId

emit

ensurePolished

enterEvent

event

eventFilter

executeDelayedItemsLayout

expand

expandAll

expandItem

expandRecursively

expandToDepth

expandsOnDoubleClick

find

findChild

findChildren

findItems

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPolicy

focusPreviousChild

focusProxy

focusWidget

font

fontInfo

fontMetrics

foregroundRole

frameGeometry

frameRect

frameShadow

frameShape

frameSize

frameStyle

frameWidth

geometry

grab

grabGesture

grabKeyboard

grabMouse

grabShortcut

graphicsEffect

graphicsProxyWidget

hasAutoScroll

hasFocus

hasHeightForWidth

hasMouseTracking

hasTabletTracking

header

headerItem

height

heightForWidth

heightMM

hide

hideColumn

hideEvent

horizontalOffset

horizontalScrollBar

horizontalScrollBarPolicy

horizontalScrollMode

horizontalScrollbarAction

horizontalScrollbarValueChanged

iconSize

indentation

indexAbove

indexAt

indexBelow

indexFromItem

indexOfTopLevelItem

indexRowSizeHint

indexWidget

inherits

initPainter

initStyleOption

initViewItemOption

inputMethodEvent

inputMethodHints

inputMethodQuery

insertAction

insertActions

insertTopLevelItem

insertTopLevelItems

installEventFilter

internalWinId

invisibleRootItem

isActiveWindow

isAncestorOf

isAnimated

isColumnHidden

isEnabled

isEnabledTo

isExpanded

isFirstColumnSpanned

isFullScreen

isHeaderHidden

isHidden

isIndexHidden

isLeftToRight

isMaximized

isMinimized

isModal

isPersistentEditorOpen

isQuickItemType

isRightToLeft

isRowHidden

isSignalConnected

isSortingEnabled

isTopLevel

isVisible

isVisibleTo

isWidgetType

isWindow

isWindowModified

isWindowType

itemAbove

itemAt

itemBelow

itemDelegate

itemDelegateForColumn

itemDelegateForIndex

itemDelegateForRow

itemFromIndex

itemWidget

itemsExpandable

keyPressEvent

keyReleaseEvent

keyboardGrabber

keyboardSearch

killTimer

layout

layoutDirection

leaveEvent

lineWidth

locale

logicalDpiX

logicalDpiY

lower

mapFrom

mapFromGlobal

mapFromParent

mapTo

mapToGlobal

mapToParent

mask

maximumHeight

maximumSize

maximumViewportSize

maximumWidth

metaObject

metric

midLineWidth

mimeData

mimeTypes

minimumHeight

minimumSize

minimumSizeHint

minimumWidth

model

mouseDoubleClickEvent

mouseGrabber

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

move

moveCursor

moveEvent

moveToThread

nativeEvent

nativeParentWidget

nextInFocusChain

normalGeometry

objectName

openPersistentEditor

overrideWindowFlags

overrideWindowState

paintEngine

paintEvent

paintingActive

palette

parent

parentWidget

physicalDpiX

physicalDpiY

pos

previousInFocusChain

property

raise_

receivers

rect

redirected

reexpand

releaseKeyboard

releaseMouse

releaseShortcut

removeAction

removeEventFilter

removeItemWidget

render

repaint

reset

resetHorizontalScrollMode

resetIndentation

resetVerticalScrollMode

resize

resizeColumnToContents

resizeEvent

restoreGeometry

rootIndex

rootIsDecorated

rowHeight

rowsAboutToBeRemoved

rowsInserted

rowsRemoved

saveGeometry

scheduleDelayedItemsLayout

screen

scroll

scrollBarWidgets

scrollContentsBy

scrollDirtyRegion

scrollTo

scrollToBottom

scrollToItem

scrollToTop

selectAll

selectedIndexes

selectedItems

selectionBehavior

selectionChanged

selectionCommand

selectionMode

selectionModel

sender

senderSignalIndex

setAcceptDrops

setAccessibleDescription

setAccessibleName

setAllColumnsShowFocus

setAlternatingRowColors

setAnimated

setAttribute

setAutoExpandDelay

setAutoFillBackground

setAutoScroll

setAutoScrollMargin

setBackgroundRole

setBaseSize

setColumnCount

setColumnHidden

setColumnWidth

setContentsMargins

setContextMenuPolicy

setCornerWidget

setCurrentIndex

setCurrentItem

setCursor

setDefaultDropAction

setDirtyRegion

setDisabled

setDragDropMode

setDragDropOverwriteMode

setDragEnabled

setDropIndicatorShown

setEditTriggers

setEnabled

setExpanded

setExpandsOnDoubleClick

setFirstColumnSpanned

setFixedHeight

setFixedSize

setFixedWidth

setFocus

setFocusPolicy

setFocusProxy

setFont

setForegroundRole

setFrameRect

setFrameShadow

setFrameShape

setFrameStyle

setGeometry

setGraphicsEffect

setHeader

setHeaderHidden

setHeaderItem

setHeaderLabel

setHeaderLabels

setHidden

setHorizontalScrollBar

setHorizontalScrollBarPolicy

setHorizontalScrollMode

setIconSize

setIndentation

setIndexWidget

setInputMethodHints

setItemDelegate

setItemDelegateForColumn

setItemDelegateForRow

setItemWidget

setItemsExpandable

setLayout

setLayoutDirection

setLineWidth

setLocale

setMask

setMaximumHeight

setMaximumSize

setMaximumWidth

setMidLineWidth

setMinimumHeight

setMinimumSize

setMinimumWidth

setModel

setMouseTracking

setObjectName

setPalette

setParent

setProperty

setRootIndex

setRootIsDecorated

setRowHidden

setScreen

setSelection

setSelectionBehavior

setSelectionMode

setSelectionModel

setShortcutAutoRepeat

setShortcutEnabled

setSizeAdjustPolicy

setSizeIncrement

setSizePolicy

setSortingEnabled

setState

setStatusTip

setStyle

setStyleSheet

setTabKeyNavigation

setTabOrder

setTabletTracking

setTextElideMode

setToolTip

setToolTipDuration

setTreePosition

setUniformRowHeights

setUpdatesEnabled

setVerticalScrollBar

setVerticalScrollBarPolicy

setVerticalScrollMode

setViewport

setViewportMargins

setVisible

setWhatsThis

setWindowFilePath

setWindowFlag

setWindowFlags

setWindowIcon

setWindowIconText

setWindowModality

setWindowModified

setWindowOpacity

setWindowRole

setWindowState

setWindowTitle

setWordWrap

setupViewport

sharedPainter

show

showColumn

showDropIndicator

showEvent

showFullScreen

showMaximized

showMinimized

showNormal

signalsBlocked

size

sizeAdjustPolicy

sizeHint

sizeHintForColumn

sizeHintForIndex

sizeHintForRow

sizeIncrement

sizePolicy

sortByColumn

sortColumn

sortItems

stackUnder

startAutoScroll

startDrag

startTimer

state

statusTip

stopAutoScroll

style

styleSheet

supportedDropActions

tabKeyNavigation

tabletEvent

takeTopLevelItem

testAttribute

textElideMode

thread

timerEvent

toolTip

toolTipDuration

topLevelItem

topLevelItemCount

topLevelWidget

tr

treePosition

underMouse

ungrabGesture

uniformRowHeights

unsetCursor

unsetLayoutDirection

unsetLocale

updateEditorData

updateEditorGeometries

updateGeometries

updateGeometry

updateMicroFocus

updatesEnabled

verticalOffset

verticalScrollBar

verticalScrollBarPolicy

verticalScrollMode

verticalScrollbarAction

verticalScrollbarValueChanged

viewport

viewportEvent

viewportMargins

viewportSizeHint

visibleRegion

visualItemRect

visualRect

visualRegionForSelection

whatsThis

wheelEvent

width

widthMM

winId

window

windowFilePath

windowFlags

windowHandle

windowIcon

windowIconText

windowModality

windowOpacity

windowRole

windowState

windowTitle

windowType

wordWrap

x

y