码迷,mamicode.com
首页 > 编程语言 > 详细

python tkinter模版

时间:2020-02-03 15:39:53      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:模版   window   date()   horizon   from   测试   set   ext   tick   

from tkinter import *
import tkinter
import time
from tkinter import ttk
import threading
import os
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(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(END)
        print("验证不通过!")
        pass
    except:
        pass

def thread():
    # while True:
        main()

window = 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=Button(window,text=‘开始‘,command=start)
button1.grid(row=0,column=2)
button2=Button(window,text=‘暂停‘,command=stop)
button2.grid(row=1,column=2)
button3=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)



mainloop()

  

python tkinter模版

标签:模版   window   date()   horizon   from   测试   set   ext   tick   

原文地址:https://www.cnblogs.com/chargeworld/p/12255662.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!