This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mathdeptv2/工具v2/guipanel.py

57 lines
2.3 KiB
Python

from PySide6.QtWidgets import QWidget, QApplication, QLineEdit, QVBoxLayout
from Ui_题号筛选器 import Ui_Form
from database_tools import *
class MyWindow(QWidget,Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.conditions = []
pro_dict = load_dict("../题库0.3/Problems.json")
self.lcdNumber_resCount.display(len(pro_dict))
self.bind()
def bind(self):
self.pushButton_content.clicked.connect(lambda: self.add_content("content"))
self.pushButton_obj.clicked.connect(lambda: self.add_content("objs"))
self.pushButton_tag.clicked.connect(lambda: self.add_content("tags"))
self.pushButton_usage.clicked.connect(lambda: self.add_content("usages"))
self.pushButton_origin.clicked.connect(lambda: self.add_content("origin"))
self.pushButton_genre.clicked.connect(lambda: self.add_content("genre"))
self.pushButton_ans.clicked.connect(lambda: self.add_content("ans"))
self.pushButton_solution.clicked.connect(lambda: self.add_content("solution"))
self.pushButton_same.clicked.connect(lambda: self.add_content("same"))
self.pushButton_related.clicked.connect(lambda: self.add_content("related"))
self.pushButton_remark.clicked.connect(lambda: self.add_content("remark"))
self.pushButton_undo.clicked.connect(self.undolast)
self.pushButton_clearAll.clicked.connect(self.clearConditions)
def add_content(self,field):
self.conditions.append((field,self.checkBox_not.isChecked(),self.lineEdit_SingleCondition.text()))
self.showConditions()
def undolast(self):
self.conditions = self.conditions[:-1].copy()
self.showConditions()
def clearConditions(self):
self.conditions = []
self.showConditions()
def showConditions(self):
text = ""
for cond in self.conditions:
field, flag_not, matchexp = cond
text += f"字段 {field}{'没有' if flag_not else ''}{''.join([t.strip() for t in matchexp.split(',')])}\n"
self.label_conditions.setText(text)
if __name__ == '__main__':
app = QApplication([])
windows = MyWindow()
windows.show()
app.exec()
#self.conditions.append(("content",True,"OBSOLETE"))