修改 文本转换处理 中的一处bug

This commit is contained in:
wangweiye7840 2024-04-28 14:19:21 +08:00
parent a3d12fcae1
commit eddc2f992d
3 changed files with 19 additions and 4 deletions

View File

@ -2819,5 +2819,12 @@ def parseRemark(string): #从一行remark字符串中分出日期和内容, 返
return date,remark
def generateProDict(cursor): #从数据库的cursor中得到problems字典的content,ans,solution,genre字段
cursor.execute("select ID,content,ans,solution,genre,origin from problems;")
ret_list = cursor.fetchall()
prodict = {ret[0]:{"content":ret[1],"ans":ret[2],"solution":ret[3],"genre":ret[4],"origin":json.loads(ret[5])} for ret in ret_list}
return prodict
if __name__ == "__main__":
print("数据库工具, import用.")

View File

@ -126,7 +126,7 @@ class MyWindow(QMainWindow,Ui_MainWindow):
self.layout_jysc.addWidget(self.jysc) #以上三行为初始化“讲义生成”tab
self.layout_wbzh = QVBoxLayout(self.tab_wbzh)
self.wbzh = MyWindow_wbzh()
self.wbzh = MyWindow_wbzh(self.database)
self.layout_wbzh.addWidget(self.wbzh) #以上三行为初始化“LaTeX代码转换”tab
self.layout_hist = QVBoxLayout(self.tab_hist)
@ -153,7 +153,8 @@ class MyWindow(QMainWindow,Ui_MainWindow):
self.dygg.setdbname,
self.bjtm.setdbname,
self.tjzd.setdbname,
self.bjjc.setdbname
self.bjjc.setdbname,
self.wbzh.setdbname
]: #在列表中的tab里传送数据库名的连接
self.sendDBname.connect(func)
def sendValue(self):

View File

@ -3,15 +3,20 @@ from Ui_文本转换处理 import Ui_Form
from database_tools_2 import *
class MyWindow_wbzh(QWidget,Ui_Form):
def __init__(self):
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_mathpix.setChecked(True)
self.pushButton_convert.clicked.connect(self.exec)
def exec(self):
raw_string = self.plainTextEdit_origin.toPlainText()
self.mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
if self.radioButton_mathpix.isChecked():
dest_string = RefineMathpix(raw_string)
elif self.radioButton_textcircled.isChecked():
@ -26,9 +31,11 @@ class MyWindow_wbzh(QWidget,Ui_Form):
elif self.radioButton_puctuations.isChecked():
dest_string = RefinePunctuations(raw_string)
elif self.radioButton_answers.isChecked():
self.pro_dict = load_dict("../题库0.3/Problems.json")
self.mycursor = self.mydb.cursor()
self.pro_dict = generateProDict(self.mycursor)
dest_string = PaintRedAnswers(raw_string,self.pro_dict)
self.plainTextEdit_dest.setPlainText(dest_string)
self.mydb.close()