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 = "测试") LabelOutputDir.insert(0,"1") print("按钮") def SetOutputDir(): try: os.mkdir(LabelOutputDir.get()) except: pass print("输出目录设为",LabelOutputDir.get()) root = Tk() outputdirectory = StringVar() outputdirectory.set(rawoutputdirectory) root.geometry("800x600") LabelTool = Label(root, text = "工具选择待定", height = 1, width = 10) 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) # 运行按钮 ButtonGo = Button(root, text ="运行", height = 1, width = 5, command = testcall) ButtonGo.place(x=600, y= 550) # 编译 root.title(rootname + " 题库工具一览") root.mainloop()