You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.3 KiB

2 years ago
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from config import items
class MyTreeWidget(QTreeWidget):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.mainwindow = parent
self.setDragEnabled(True)
# 选中不显示虚线
# self.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.setFocusPolicy(Qt.NoFocus)
class FuncTreeWidget(QTreeWidget):
def __init__(self, parent=None):
super(FuncTreeWidget, self).__init__(parent)
self.mainwindow = parent
# 根节点
root1 = QTreeWidgetItem(self)
root1.setText(0, '重构') # 0代表第一列即Key列
root1.setIcon(0, QIcon('icons/color.png')) # 为节点设置图标
self.setColumnWidth(0, 200) # 第一列列宽设为200
self.header().hide()
self.itemClicked.connect(self.function)
# 添加子节点1
child1 = QTreeWidgetItem(root1)
child1.setText(0, '裁剪')
child1.setIcon(0, QIcon('icons/color.png'))
root2 = QTreeWidgetItem(self)
root2.setText(0, '调整') # 第一列Key为 子节点1
root2.setIcon(0, QIcon('icons/color.png'))
child4 = QTreeWidgetItem(root2)
child4.setText(0, '光效')
child4.setIcon(0, QIcon('icons/color.png'))
child5 = QTreeWidgetItem(root2)
child5.setText(0, '色彩')
child5.setIcon(0, QIcon('icons/color.png'))
child6 = QTreeWidgetItem(root2)
child6.setText(0, 'HSL')
child6.setIcon(0, QIcon('icons/color.png'))
child8 = QTreeWidgetItem(root2)
child8.setText(0, '质感')
child8.setIcon(0, QIcon('icons/color.png'))
child10 = QTreeWidgetItem(root2)
child10.setText(0, '特效')
child10.setIcon(0, QIcon('icons/color.png'))
root3 = QTreeWidgetItem(self)
root3.setText(0, '风格迁移')
root3.setIcon(0, QIcon('icons/color.png'))
root4 = QTreeWidgetItem(self)
root4.setText(0, '其他操作')
root4.setIcon(0, QIcon('icons/color.png'))
# 默认所有节点都处于展开状态
# self.expandAll()
def function(self):
func_item = self.currentItem()
self.mainwindow.update_dock(func_item.text(0))