from tkinter import * from subprocess import call import os root = Tk() root.geometry('800x600') root.title('题库v2.0工具面板') def temp(): pass def SetButton1(str): commandname.set(str) LabelTool.config(text = str) button1.place(x = 600, y = 550) button2.place_forget() 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"]) LabelTool.config(text = "STEP1命令执行完毕") def run_command2(): selectedtool = commandname.get() if selectedtool == "添加关联题目": call(["python","导入关联题目.py"]) elif selectedtool == "修改题目数据库": call(["python","修改结果汇入.py"]) LabelTool.config(text = "STEP2命令执行完毕") commandname = StringVar() commandname.set("none") LabelTool = Label(root, text = "工具选择待定", height = 1, width = 25, 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: (commandname.set("寻找空闲题号"),LabelTool.config(text = "寻找空闲题号"),button1.place(x = 600, y = 550),button2.place_forget())) ImportMenu.add_separator() ImportMenu.add_command(label = "批量收录题目", command = lambda: (commandname.set("批量收录题目"),LabelTool.config(text = "批量收录题目"),button1.place(x = 600, y = 550),button2.place_forget(),os.system("code 批量收录题目.py"))) ImportMenu.add_command(label = "添加关联题目", command = lambda: (commandname.set("添加关联题目"),LabelTool.config(text = "添加关联题目(两阶段)"),button1.place(x = 600, y = 550),button2.place(x = 700, y = 550),os.system("code 添加关联题目.py"))) # 设置 维护 菜单项 MaintainenceMenu = Menu(menubar, tearoff = False) menubar.add_cascade(label = "维护", menu = MaintainenceMenu) MaintainenceMenu.add_command(label = "修改题目", command = lambda: (commandname.set("修改题目数据库"),LabelTool.config(text = "修改题目(两阶段)"),button1.place(x = 600, y = 550),button2.place(x = 700, y = 550),os.system("code 修改题目数据库.py"))) # 设置 使用 菜单项 UseMenu = Menu(menubar, tearoff = False) menubar.add_cascade(label = "使用", menu = UseMenu) UseMenu.add_command(label = "题号选题pdf生成", command = lambda: (commandname.set("题号选题pdf生成"),LabelTool.config(text = "题号选题pdf生成"),button1.place(x = 600, y = 550),button2.place_forget(),os.system("code 题号选题pdf生成.py"))) # 设置 其他 菜单项 OtherMenu = Menu(menubar, tearoff = False) menubar.add_cascade(label = "其他", menu = OtherMenu) OtherMenu.add_command(label = "mathpix预处理", command = lambda: (commandname.set("mathpix预处理"),LabelTool.config(text = "mathpix预处理"),button1.place(x = 600, y = 550),button2.place_forget())) OtherMenu.add_command(label = "带圈数字处理", command = lambda: (commandname.set("带圈数字处理"),LabelTool.config(text = "带圈数字处理"),button1.place(x = 600, y = 550),button2.place_forget())) menubar.add_command(label = "退出", command = root.destroy) root.config(menu = menubar) root.mainloop()