您的位置:首页技术文章
文章详情页

python2.7为什么点击了"开始"按钮后,tkinter上的按钮,图中红色部分,再也点不动了?

【字号: 日期:2022-06-29 18:51:57浏览:56作者:猪猪

问题描述

python2.7为什么点击了'开始'按钮后,tkinter上的按钮,图中红色部分,再也点不动了?如何能在点击'开始'按钮后,还能点击tkinter的最小化,最大化和关闭按钮?代码为:

# -*- coding: UTF-8 -*-from Tkinter import *import osimport tkMessageBoximport timeroot = Tk()today_path = time.strftime(’%Y-%m-%d’)work_path = ’C:yes_pic’ + today_pathdef start(): while True:doThis(work_path)time.sleep(5)def doThis(dirr): if not os.path.exists(dirr):pass else:if os.path.isdir(dirr): for p in os.listdir(dirr):d = os.path.join(dirr,p)if (os.path.isdir(d) == True): doThis(d)if os.listdir(dirr): if dirr.count(’’)!=2:tkMessageBox.showwarning('提示', '路径'+dirr+'有文件!')button = Button(root, text='开始', command=start,width=20,height=10)button.pack()root.geometry(’300x200+500+300’)root.mainloop()

python2.7为什么点击了"开始"按钮后,tkinter上的按钮,图中红色部分,再也点不动了?

问题解答

回答1:

因为你在start里面写的是死循环,永远不会结束你应该新启一个子线程才对

标签: Python 编程