1 # """小白随笔,大佬勿喷 2 # ‘‘‘tkinter解决time延迟问题‘‘‘ 3 # """ 4 # import tkinter as tk 5 # import time 6 # import threading 7 8 # #初始化窗口 9 # window = tk.Tk() 10 # #窗口名称 11 # window.title("My Window") 12 # #窗口大小,是 x 不是 * 13 # window.geometry("400x400") 14 # #不能改变窗口的大小 15 # window.resizable(width=False,height=False) 16 # def count(): 17 # label = tk.Label(window,bg="green") 18 # label.pack() 19 # button.pack() 20 # while True: 21 # try: 22 # #获取当前时间 23 # date = time.strftime("%Y-%m-%d\n%H:%M:%S") 24 # label.config(text=date) 25 # #更新窗口 26 # window.update() 27 # time.sleep(1) 28 # except: 29 # break 30 # #创建按钮,只是为了测试sleep与按钮之间是否存在延迟 31 # button = tk.Button(window,text="Hit_me",width=20) 32 # #创建线程,如果函数里面有参数,args=() 33 # t = threading.Thread(target=count) 34 # #开启线程 35 # t.start() 36 # #循环窗口 37 # window.mainloop() 38 # ===================================================================================================== 39 # from tkinter import * 40 # import time 41 # import threading 42 # 43 # event = threading.Event() 44 # def start(): 45 # event.set() 46 # t1 = threading.Thread(target=thread) 47 # t1.setDaemon(True) 48 # t1.start() 49 # def stop(): 50 # event.clear() 51 # print('暂停') 52 # def conti(): 53 # event.set() 54 # print('继续') 55 # def thread(): 56 # while True: 57 # print('运行中') 58 # time.sleep(1) 59 # event.wait() 60 # window = Tk() 61 # window.title('测试') 62 # b1=Button(window,text='start',command=start) 63 # b1.pack() 64 # b2=Button(window,text='stop',command=stop) 65 # b2.pack() 66 # b3=Button(window,text='conti',command=conti) 67 # b3.pack() 68 # mainloop() 69 70 # ===================================================================================================== 71 # """ 72 # @Author : 行初心 73 # @Date : 18-10-1 74 # @Blog : www.cnblogs.com/xingchuxin 75 # @Gitee : gitee.com/zhichengjiu 76 # """ 77 # from tkinter import * 78 # 79 # def main(): 80 # root = Tk() 81 # scrolly = Scrollbar(root) 82 # scrolly.pack(side=RIGHT, fill=Y) 83 # mylb = Listbox(root, yscrollcommand=scrolly.set) 84 # for item in range(1, 20): 85 # mylb.insert(END, item) 86 # mylb.pack() 87 # scrolly.config(command=mylb.yview) 88 # mainloop() 89 # if __name__ == '__main__': 90 # main() 91 # =====================================================================================================
#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=
本文来自博客园,作者:凡是过去,皆为序曲,转载请注明原文链接:https://www.cnblogs.com/longhai3/p/15887896.html
如有疑问,欢迎提问
#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=