2012-05-31 20:05:19 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-02-25 04:09:03 +00:00
|
|
|
"""
|
|
|
|
Simple demonstration of TreeWidget, which is an extension of QTreeWidget
|
|
|
|
that allows widgets to be added and dragged within the tree more easily.
|
|
|
|
"""
|
2012-05-31 20:05:19 +00:00
|
|
|
import initExample ## Add path to library (just for examples; you do not need this)
|
|
|
|
|
|
|
|
import pyqtgraph as pg
|
|
|
|
from pyqtgraph.Qt import QtCore, QtGui
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
2021-01-27 18:59:07 +00:00
|
|
|
app = pg.mkQApp("TreeWidget Example")
|
2012-05-31 20:05:19 +00:00
|
|
|
|
|
|
|
w = pg.TreeWidget()
|
|
|
|
w.setColumnCount(2)
|
|
|
|
w.show()
|
2013-02-25 04:09:03 +00:00
|
|
|
w.setWindowTitle('pyqtgraph example: TreeWidget')
|
2012-05-31 20:05:19 +00:00
|
|
|
|
|
|
|
i1 = QtGui.QTreeWidgetItem(["Item 1"])
|
|
|
|
i11 = QtGui.QTreeWidgetItem(["Item 1.1"])
|
|
|
|
i12 = QtGui.QTreeWidgetItem(["Item 1.2"])
|
|
|
|
i2 = QtGui.QTreeWidgetItem(["Item 2"])
|
|
|
|
i21 = QtGui.QTreeWidgetItem(["Item 2.1"])
|
2012-08-17 20:11:30 +00:00
|
|
|
i211 = pg.TreeWidgetItem(["Item 2.1.1"])
|
|
|
|
i212 = pg.TreeWidgetItem(["Item 2.1.2"])
|
|
|
|
i22 = pg.TreeWidgetItem(["Item 2.2"])
|
|
|
|
i3 = pg.TreeWidgetItem(["Item 3"])
|
|
|
|
i4 = pg.TreeWidgetItem(["Item 4"])
|
|
|
|
i5 = pg.TreeWidgetItem(["Item 5"])
|
|
|
|
b5 = QtGui.QPushButton('Button')
|
|
|
|
i5.setWidget(1, b5)
|
|
|
|
|
|
|
|
|
2012-05-31 20:05:19 +00:00
|
|
|
|
|
|
|
w.addTopLevelItem(i1)
|
|
|
|
w.addTopLevelItem(i2)
|
|
|
|
w.addTopLevelItem(i3)
|
|
|
|
w.addTopLevelItem(i4)
|
|
|
|
w.addTopLevelItem(i5)
|
|
|
|
i1.addChild(i11)
|
|
|
|
i1.addChild(i12)
|
|
|
|
i2.addChild(i21)
|
|
|
|
i21.addChild(i211)
|
|
|
|
i21.addChild(i212)
|
|
|
|
i2.addChild(i22)
|
|
|
|
|
2012-08-17 20:11:30 +00:00
|
|
|
b1 = QtGui.QPushButton("Button")
|
2012-05-31 20:05:19 +00:00
|
|
|
w.setItemWidget(i1, 1, b1)
|
|
|
|
|
2012-12-05 05:25:45 +00:00
|
|
|
if __name__ == '__main__':
|
2021-05-13 21:28:22 +00:00
|
|
|
pg.exec()
|