|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
为什么While函数里面的那个time.time() - begintime >=1,begintime为什么要自增1?
def auto_selectthree(begintime): #自制不精确的计时器,线程函数
global label_auto
global autoflag
try:
duration = int(input_time.get())
except:
tk.messagebox.showerror("错误!","您输入的不是整数")
return
if (autoflag ==1):
btn_next_click()
else:
pass
while (autoflag == 1):
if (time.time() - begintime >= 1 and duration > 0):
begintime = begintime + 1
duration = duration - 1
label_auto["text"] = str(duration) + "秒后自动"
elif (duration <= 0):
label_auto["text"] = "查询数据中..."
btn_next_click()
duration = int(input_time.get())
begintime = time.time()
label_auto["text"] = str(duration) + "秒后自动"
else:
pass
label_auto["text"] = "已停止"
def btn_start_clickthree():
global label_path
global photo_repository
if (len(photo_repository) == 0):
tk.messagebox.showinfo("警告", "先选择照片所在的文件夹!")
else:
global autoflag
global auto_selectthree
if (autoflag == True):
pass
else:
import threading
autoflag = 1
label_auto["text"] = input_time.get()+"秒后自动"
threading._start_new_thread(auto_selectthree, (time.time(),)) #auto_selectthree为线程函数,time.time()为传给线程函数的参数
def btn_stop_click():
global autoflag
global label_auto
autoflag = 0
label_auto["text"] = "已停止" |
|