70 lines
2.7 KiB
Python
70 lines
2.7 KiB
Python
from PySide6.QtWidgets import QWidget, QApplication, QLineEdit, QCheckBox
|
|
from Ui_赋能卷生成 import Ui_Form
|
|
from database_tools_2 import *
|
|
|
|
class MyWindow_fnsc(QWidget,Ui_Form):
|
|
def __init__(self,database_name):
|
|
super().__init__()
|
|
self.database_name = database_name
|
|
self.setupUi(self)
|
|
self.bind()
|
|
def setdbname(self,string):
|
|
self.database_name = string
|
|
# print(self.database_name)
|
|
def bind(self):
|
|
self.radioButton_min.setChecked(True)
|
|
self.pushButton_exec.clicked.connect(self.exec)
|
|
self.pushButton_sel_all.clicked.connect(self.selectall)
|
|
self.pushButton_sel_rev.clicked.connect(self.selectrev)
|
|
|
|
def selectall(self):
|
|
for self.checkbox in self.findChildren(QCheckBox):
|
|
self.checkbox.setChecked(True)
|
|
|
|
def selectrev(self):
|
|
for self.checkbox in self.findChildren(QCheckBox):
|
|
self.checkbox.setChecked(not self.checkbox.isChecked())
|
|
|
|
|
|
|
|
|
|
def exec(self):
|
|
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
|
|
mycursor = mydb.cursor()
|
|
pro_dict,obj_dict,bn_dict,unit_obj_dict = generateDictsfromMariaDB(mycursor)
|
|
units_list = []
|
|
for self.checkbox in self.findChildren(QCheckBox):
|
|
if self.checkbox.isChecked():
|
|
units_list.append(self.checkbox.text()[:4])
|
|
genre_tuple = (int(self.lineEdit_tiankongcount.text()),int(self.lineEdit_xuanzecount.text()))
|
|
diffinterval = (float(self.lineEdit_diff_lowerbound.text()),float(self.lineEdit_diff_upperbound.text()))
|
|
if self.radioButton_min.isChecked():
|
|
method = "min"
|
|
elif self.radioButton_max.isChecked():
|
|
method = "max"
|
|
elif self.radioButton_average.isChecked():
|
|
method = "average"
|
|
elif self.radioButton_median.isChecked():
|
|
method = "median"
|
|
sim_threshold = float(self.lineEdit_threshold.text())
|
|
excludeids = findxiaobenIDs(mycursor,grade = self.lineEdit_grade.text())
|
|
mydb.close()
|
|
papercount = int(self.lineEdit_papercount.text())
|
|
output = ""
|
|
for i in range(papercount):
|
|
tiankongids, xuanzeids = generate_adaptive_problemIDs(pro_dict=pro_dict,units_list=units_list,genre_tuple=genre_tuple,diffinterval=diffinterval,method=method,excludeids=excludeids,sim_threshold=sim_threshold)
|
|
idstr = ",".join(tiankongids+xuanzeids)
|
|
output += f"赋能{(i+1):2d}: {idstr}\n"
|
|
self.plainTextEdit_output.setPlainText(output)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app = QApplication([])
|
|
windows = MyWindow_fnsc("tikutest")
|
|
windows.show()
|
|
app.exec()
|
|
|