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/工具/工具面板.py

98 lines
3.7 KiB
Python

from tkinter import *
from subprocess import call
import os
root = Tk()
root.geometry('800x600')
root.title('题库v2.0工具面板')
def temp():
pass
def SetButton(str,numbuttons,openfilelist):
commandname.set(str)
LabelTool.config(text = str)
button1.place(x = 600, y = 550)
if numbuttons == 1:
button2.place_forget()
else:
button2.place(x=700, y=550)
for f in openfilelist:
os.system("code "+f)
def run_command1():
selectedtool = commandname.get()
if selectedtool == "题号选题pdf生成":
call(["python","题号选题pdf生成.py"])
elif selectedtool == "寻找空闲题号":
call(["python","寻找空闲题号.py"])
elif selectedtool == "批量收录题目":
call(["python","批量收录题目.py"])
elif selectedtool == "添加关联题目":
call(["python","添加关联题目.py"])
elif selectedtool == "修改题目数据库":
call(["python","修改题目数据库.py"])
elif selectedtool == "mathpix预处理":
call(["python","../文本处理工具/剪贴板文本整理_mathpix.py"])
elif selectedtool == "带圈数字处理":
call(["python","../文本处理工具/带圈数字处理.py"])
elif selectedtool == "试卷答案生成":
call(["python","试卷答案生成.py"])
LabelTool.config(text = selectedtool+" STEP1命令执行完毕")
def run_command2():
selectedtool = commandname.get()
if selectedtool == "添加关联题目":
call(["python","导入关联题目.py"])
elif selectedtool == "修改题目数据库":
call(["python","修改结果汇入.py"])
LabelTool.config(text = selectedtool+ "STEP2命令执行完毕")
commandname = StringVar()
commandname.set("none")
LabelTool = Label(root, text = "工具选择待定", height = 1, width = 40, anchor=W)
LabelTool.place(x=420,y=50)
button1 = Button(root, text = "运行STEP1", command = run_command1)
button2 = Button(root, text = "运行STEP2", command = run_command2)
# button3 = Button(root, text = "运行STEP3")
menubar = Menu(root)
# 设置 录入 菜单项
ImportMenu = Menu(menubar, tearoff = False)
menubar.add_cascade(label = "录入", menu = ImportMenu)
ImportMenu.add_command(label = "寻找空闲题号", command = lambda: SetButton("寻找空闲题号",1,[]))
ImportMenu.add_separator()
ImportMenu.add_command(label = "批量收录题目", command = lambda: SetButton("批量收录题目",1,["批量收录题目.py"]))
ImportMenu.add_command(label = "添加关联题目", command = lambda: SetButton("添加关联题目",2,["添加关联题目.py"]))
# 设置 维护 菜单项
MaintainenceMenu = Menu(menubar, tearoff = False)
menubar.add_cascade(label = "维护", menu = MaintainenceMenu)
MaintainenceMenu.add_command(label = "修改题目", command = lambda: SetButton("修改题目数据库",2,["修改题目数据库.py"]))
# 设置 使用 菜单项
UseMenu = Menu(menubar, tearoff = False)
menubar.add_cascade(label = "使用", menu = UseMenu)
UseMenu.add_command(label = "题号选题pdf生成", command = lambda: SetButton("题号选题pdf生成",1,["题号选题pdf生成.py"]))
UseMenu.add_command(label = "试卷答案生成", command = lambda: SetButton("试卷答案生成",1,["试卷答案生成.py"]))
# 设置 其他 菜单项
OtherMenu = Menu(menubar, tearoff = False)
menubar.add_cascade(label = "其他", menu = OtherMenu)
OtherMenu.add_command(label = "mathpix预处理", command = lambda: SetButton("mathpix预处理",1,[]))
OtherMenu.add_command(label = "带圈数字处理", command = lambda: SetButton("带圈数字处理",1,[]))
menubar.add_command(label = "退出", command = root.destroy)
root.config(menu = menubar)
root.mainloop()