-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserDetail.py
114 lines (108 loc) · 5.48 KB
/
UserDetail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Detail.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class Ui_User_Detail_Dialog(object):
def setupUi(self, Dialog, RuleDetail):
# RuleDetail should be a dict wrapping the details of a rule.
print(RuleDetail)
Dialog.setObjectName("Dialog")
Dialog.resize(741, 245)
self.dialog = Dialog
self.tableWidget = QtWidgets.QTableWidget(Dialog)
self.tableWidget.setGeometry(QtCore.QRect(20, 30, 711, 141))
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(7)
self.tableWidget.setRowCount(0)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(5, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(6, item)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(340, 210, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Dialog)
self.parseRule(RuleDetail)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("Dialog", "规则类型"))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("Dialog", "作用对象"))
item = self.tableWidget.horizontalHeaderItem(2)
item.setText(_translate("Dialog", "逻辑操作"))
item = self.tableWidget.horizontalHeaderItem(3)
item.setText(_translate("Dialog", "值"))
item = self.tableWidget.horizontalHeaderItem(4)
item.setText(_translate("Dialog", "作用范围"))
item = self.tableWidget.horizontalHeaderItem(5)
item.setText(_translate("Dialog", "规则描述"))
self.pushButton.setText(_translate("Dialog", "关闭"))
self.pushButton.clicked.connect(self.close)
def parseRule(self, RuleDetail):
_translate = QtCore.QCoreApplication.translate
for i in range(len(RuleDetail['simpleRules'])):
j = 0
row = self.tableWidget.rowCount()
self.tableWidget.insertRow(row)
item = QtWidgets.QTableWidgetItem('用户规则')
item.setTextAlignment(QtCore.Qt.AlignCenter)
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.tableWidget.setItem(i, j, item)
j += 1
applyTarget = {"主语的数量":"subject_count","主语的值":"subject_Val","宾语的值":"object_Val","宾语的数量":"object_count",
"动词的数量":"verb_count","动词的时态":"verb_tense","句子中所有词语":"strs","情态动词的数量":"modal_verb_count",
"副词的数量":"adverb_count","代词的数量":"pronoun_count"}
applyTarget= dict(zip(applyTarget.values(), applyTarget.keys()))
item = QtWidgets.QTableWidgetItem(applyTarget[RuleDetail['simpleRules'][i]['subject']])
item.setTextAlignment(QtCore.Qt.AlignCenter)
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.tableWidget.setItem(i, j, item)
j += 1
ops = {"in":"在","notIn":"不在","ge":"大于等于","gt":"大于","lt":"小于","le":"小于等于","eq":"等于","neq":"不等于"}
item = QtWidgets.QTableWidgetItem(ops[RuleDetail['simpleRules'][i]['operation']])
item.setTextAlignment(QtCore.Qt.AlignCenter)
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.tableWidget.setItem(i, j, item)
j += 1
item = QtWidgets.QTableWidgetItem(str(RuleDetail['simpleRules'][i]['val']))
item.setTextAlignment(QtCore.Qt.AlignCenter)
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.tableWidget.setItem(i, j, item)
j += 1
applyScopes = {"所有句子":"allSentence","动作句子":"actionStep"}
applyScopes= dict(zip(applyScopes.values(),applyScopes.keys()))
item = QtWidgets.QTableWidgetItem(applyScopes[RuleDetail['applyScope']])
item.setTextAlignment(QtCore.Qt.AlignCenter)
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.tableWidget.setItem(i, j, item)
j += 1
item = QtWidgets.QTableWidgetItem(RuleDetail['description'])
item.setTextAlignment(QtCore.Qt.AlignCenter)
item.setFlags(QtCore.Qt.ItemIsEnabled)
self.tableWidget.setItem(i, j, item)
def close(self):
self.dialog.close()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_Dialog()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())