python tkinter模版
import tkinter import time import threading from tkinter import ttk event = threading.Event() once=0 def start(): global once if once==1: # event.set() # print('继续') pass else: event.set() t1 = threading.Thread(target=thread) # print(threading.currentThread()) //获取线程id t1.setDaemon(True) # validate() t1.start() print("开始") once+=1 def stop(): event.clear() print('暂停') def conti(): event.set() print('继续') def main(): try: print(s1.get(),s2.get()) for i in range(0, 30): mpb["value"] = i text.see(tkinter.END) # 一直查看文本的最后位置~ text.insert('end', "验证不通过,请查看!" + str(i) + "\r\n") # scale.config(mode='determinate', maximum=11.0, value=i) text.update() # 一直更新输出 print(i) time.sleep(0.1) event.wait() window.update() text.insert('end', "程序运行完成!" + "\r\n") text.update() text.see(tkinter.END) print("验证不通过!") pass except: pass def thread(): # while True: main() window = tkinter.Tk() window.title('测试') # l1=tkinter.Label(text="word输出文件路径") l1.grid(row=0,column=0) # e1=tkinter.Entry("") s1 = tkinter.StringVar() entry1 = tkinter.Entry(window, textvariable=s1) entry1.grid(row=0,column=1) l2=tkinter.Label(text="Excel文件路径") l2.grid(row=1,column=0) # e2=tkinter.Entry("") s2 = tkinter.StringVar() entry2 = tkinter.Entry(window, textvariable=s2) entry2.grid(row=1,column=1) i=0 mpb = ttk.Progressbar(window, orient="horizontal", length=200, value=0,mode="determinate") mpb.grid(row=2,column=0,columnspan=2) button1=tkinter.Button(window,text='开始',command=start) button1.grid(row=0,column=2) button2=tkinter.Button(window,text='暂停',command=stop) button2.grid(row=1,column=2) button3=tkinter.Button(window,text='继续',command=conti) button3.grid(row=2,column=2) from tkinter import scrolledtext # 导入滚动文本框的模块 scrolW = 50 # 设置文本框的长度 scrolH = 18 # 设置文本框的高度 text = scrolledtext.ScrolledText(window, width=scrolW, height=scrolH, wrap=tkinter.WORD) text.grid(row=10, columnspan=8, sticky=tkinter.E) tkinter.mainloop()