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/工具/tools panel.py

119 lines
4.2 KiB
Python

from tkinter import *
import os
from subprocess import call
#设置根目录名
rootname = "mathdeptv2"
rawoutputdirectory = "d:/temp/tkoutput"
try:
os.mkdir(rawoutputdirectory)
except:
pass
def testcall():
LabelTool.config(text = commandname.get())
print(commandname.get())
def SetOutputDir():
try:
os.mkdir(LabelOutputDir.get())
except:
pass
print("输出目录设为",LabelOutputDir.get())
def run_command():
selectedtool = commandname.get()
if selectedtool == "题号选题pdf生成":
call(["python","题号选题pdf生成.py"])
elif selectedtool == "寻找空闲题号":
call(["python","寻找空闲题号.py"])
elif selectedtool == "批量收录题目":
call(["python","批量收录题目.py"])
elif selectedtool == "添加关联题目STEP1":
call(["python","添加关联题目.py"])
elif selectedtool == "添加关联题目STEP2":
call(["python","导入关联题目.py"])
elif selectedtool == "修改题目STEP1":
call(["python","修改题目数据库.py"])
elif selectedtool == "修改题目STEP2":
call(["python","修改结果汇入.py"])
elif selectedtool == "mathpix预处理":
call(["python","../文本处理工具/剪贴板文本整理_mathpix.py"])
root = Tk()
outputdirectory = StringVar()
outputdirectory.set(rawoutputdirectory)
commandname = StringVar()
commandname.set("none")
print(commandname.get())
root.geometry("800x600")
LabelTool = Label(root, text = "工具选择待定", height = 1, width = 25, anchor=W)
LabelTool.place(x=420,y=50)
# 设置输出目录名
LabelOutputDir = Entry(root,textvariable=outputdirectory)
LabelOutputDir.place(x = 420, y = 120, width = 250)
# 修改输出目录按钮
ButtonDir = Button(root,text = "输出目录确定", command = SetOutputDir)
ButtonDir.place(x=700, y=120)
# 题目导入标签
LabelAPPEND = Label(root, text = "题目导入")
LabelAPPEND.place(x=20,y=0)
# 寻找空闲题号按钮
ButtonKXTH = Button(root, text = "寻找空闲题号", command = lambda: (commandname.set("寻找空闲题号"),LabelTool.config(text = "寻找空闲题号")))
ButtonKXTH.place(x=20,y=20)
# 批量收录题目按钮
ButtonSLTM = Button(root, text = "批量收录题目", command = lambda: (commandname.set("批量收录题目"),LabelTool.config(text = "批量收录题目"),os.system("code 批量收录题目.py")))
ButtonSLTM.place(x=20,y=50)
# 添加关联题目STEP1按钮
ButtonTJGL = Button(root, text = "添加关联题目STEP1", command = lambda: (commandname.set("添加关联题目STEP1"),LabelTool.config(text = "添加关联题目STEP1"),os.system("code 添加关联题目.py")))
ButtonTJGL.place(x=20,y=80)
# 添加关联题目STEP2按钮
ButtonTJGL2 = Button(root, text = "添加关联题目STEP2", command = lambda: (commandname.set("添加关联题目STEP2"),LabelTool.config(text = "添加关联题目STEP2")))
ButtonTJGL2.place(x=140,y=80)
# 题库维护标签
LabelMAINTAINENCE = Label(root, text = "题库维护")
LabelMAINTAINENCE.place(x=20,y=200)
# 修改题目STEP1按钮
ButtonTJGL = Button(root, text = "修改题目STEP1", command = lambda: (commandname.set("修改题目STEP1"),LabelTool.config(text = "修改题目STEP1"),os.system("code 修改题目数据库.py")))
ButtonTJGL.place(x=20,y=220)
# 修改题目STEP2按钮
ButtonTJGL2 = Button(root, text = "修改题目STEP2", command = lambda: (commandname.set("修改题目STEP2"),LabelTool.config(text = "修改题目STEP2")))
ButtonTJGL2.place(x=120,y=220)
# 题库使用标签
LabelUSE = Label(root, text = "题库使用")
LabelUSE.place(x=20,y=400)
# 题号选题pdf生成按钮
ButtonTHXT = Button(root, text = "题号选题pdf生成", command = lambda: (commandname.set("题号选题pdf生成"),LabelTool.config(text = "题号选题pdf生成")))
ButtonTHXT.place(x=20,y=420)
# 剪贴板文字处理按钮
ButtonClip = Button(root, text = "mathpix预处理", height= 1, width = 13, command = lambda: (commandname.set("mathpix预处理"),LabelTool.config(text = "mathpix预处理")))
ButtonClip.place(x=420, y = 550)
# 运行按钮
ButtonGo = Button(root, text ="运行", height = 1, width = 5, command = run_command)
ButtonGo.place(x=600, y= 550)
# 编译
root.title(rootname + " 题库工具一览")
root.mainloop()