From 1d481eb1ed85e97254d6b587a46c8a19f13b8cb2 Mon Sep 17 00:00:00 2001 From: Irony <892768447@qq.com> Date: Tue, 4 Jun 2019 14:11:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .settings/org.eclipse.core.resources.prefs | 1 + QTreeWidget/{ => Data}/testTree.ui | 0 QTreeWidget/Lib/__init__.py | 0 QTreeWidget/Lib/testTree.py | 57 ++++++++++++++++++++++ QTreeWidget/__init__.py | 0 QTreeWidget/testTreeWidget.py | 18 ++++--- 6 files changed, 69 insertions(+), 7 deletions(-) rename QTreeWidget/{ => Data}/testTree.ui (100%) create mode 100644 QTreeWidget/Lib/__init__.py create mode 100644 QTreeWidget/Lib/testTree.py create mode 100644 QTreeWidget/__init__.py diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 75d5031..1cedc92 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -53,6 +53,7 @@ encoding//QSplitter/RewriteHandle.py=utf-8 encoding//QTableWidget/TableWidget.py=utf-8 encoding//QThread/moveToThread.py=utf-8 encoding//QTreeWidget/ParsingJson.py=utf-8 +encoding//QTreeWidget/testTreeWidget.py=utf-8 encoding//QWebEngineView/GetCookie.py=utf-8 encoding//QWebEngineView/JsSignals.py=utf-8 encoding//QWebView/DreamTree.py=utf-8 diff --git a/QTreeWidget/testTree.ui b/QTreeWidget/Data/testTree.ui similarity index 100% rename from QTreeWidget/testTree.ui rename to QTreeWidget/Data/testTree.ui diff --git a/QTreeWidget/Lib/__init__.py b/QTreeWidget/Lib/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/QTreeWidget/Lib/testTree.py b/QTreeWidget/Lib/testTree.py new file mode 100644 index 0000000..647f005 --- /dev/null +++ b/QTreeWidget/Lib/testTree.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'testTree.ui' +# +# Created by: PyQt5 UI code generator 5.10.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(719, 544) + self.treeWidget = QtWidgets.QTreeWidget(Form) + self.treeWidget.setGeometry(QtCore.QRect(80, 80, 256, 192)) + self.treeWidget.setObjectName("treeWidget") + item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget) + item_0.setCheckState(0, QtCore.Qt.Unchecked) + item_1 = QtWidgets.QTreeWidgetItem(item_0) + item_1.setCheckState(0, QtCore.Qt.Unchecked) + item_1 = QtWidgets.QTreeWidgetItem(item_0) + item_1.setCheckState(0, QtCore.Qt.Unchecked) + item_1 = QtWidgets.QTreeWidgetItem(item_0) + item_1.setCheckState(0, QtCore.Qt.Unchecked) + item_1 = QtWidgets.QTreeWidgetItem(item_0) + item_1.setCheckState(0, QtCore.Qt.Unchecked) + item_1 = QtWidgets.QTreeWidgetItem(item_0) + item_1.setCheckState(0, QtCore.Qt.Unchecked) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.treeWidget.headerItem().setText(0, _translate("Form", "测试")) + __sortingEnabled = self.treeWidget.isSortingEnabled() + self.treeWidget.setSortingEnabled(False) + self.treeWidget.topLevelItem(0).setText(0, _translate("Form", "测试1")) + self.treeWidget.topLevelItem(0).child(0).setText(0, _translate("Form", "子节点1")) + self.treeWidget.topLevelItem(0).child(1).setText(0, _translate("Form", "字节点2")) + self.treeWidget.topLevelItem(0).child(2).setText(0, _translate("Form", "字节点3")) + self.treeWidget.topLevelItem(0).child(3).setText(0, _translate("Form", "字节点4")) + self.treeWidget.topLevelItem(0).child(4).setText(0, _translate("Form", "字节点5")) + self.treeWidget.setSortingEnabled(__sortingEnabled) + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + Form = QtWidgets.QWidget() + ui = Ui_Form() + ui.setupUi(Form) + Form.show() + sys.exit(app.exec_()) + diff --git a/QTreeWidget/__init__.py b/QTreeWidget/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/QTreeWidget/testTreeWidget.py b/QTreeWidget/testTreeWidget.py index 30420d1..39aecad 100644 --- a/QTreeWidget/testTreeWidget.py +++ b/QTreeWidget/testTreeWidget.py @@ -9,28 +9,32 @@ Created on 2017年4月20日 @description: ''' import sys + from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDialog, QApplication -from QTreeWidget.testTree import Ui_Form -class graphAnalysis(QDialog,Ui_Form): +from Lib.testTree import Ui_Form # @UnresolvedImport + + +class graphAnalysis(QDialog, Ui_Form): def __init__(self): super(graphAnalysis, self).__init__() self.setupUi(self) # 点击父节点 self.treeWidget.itemChanged.connect(self.handleChanged) - def handleChanged(self,item,column): + + def handleChanged(self, item, column): count = item.childCount() if item.checkState(column) == Qt.Checked: for index in range(count): - item.child(index).setCheckState(0,Qt.Checked) + item.child(index).setCheckState(0, Qt.Checked) if item.checkState(column) == Qt.Unchecked: for index in range(count): - item.child(index).setCheckState(0,Qt.Unchecked) + item.child(index).setCheckState(0, Qt.Unchecked) -if __name__ =="__main__": +if __name__ == "__main__": app = QApplication(sys.argv) w = graphAnalysis() w.show() - sys.exit(app.exec_()) \ No newline at end of file + sys.exit(app.exec_())