一、功能介绍:
1.本质就是个倒计时的工具;
2.两种模式:
2.1开始倒数:在“计划表”框中,按照“ YYYY-M-D hh:mm:ss”格式输入时间,即可按照当前电脑时间进行倒数计时,以进度条显示经过;
2.2开始计划:点击“计划表”后的选择文件,选择计划文件.xlsx,之后即可按照计划表内的计划倒数计时,以进度条显示当前计划时间进度和总计划完成进度。计划文件需要满足,A1填入时间,并在A列填入需要规划的时间;B1填入计划名称,B列填入需要规划的计划内容。为了保证A列内容不变,建议使用单元格格式为“文本”,示例如下:
2.3缺陷:
1、使用openpyxl,打包后程序虚胖,不影响实际使用(划掉);
2、使用xrld只支持读取.xls格式文件。
二、演示:
模式一:
模式二:
三、程序包:
clock.dist.rar
最终还是为了小一些,更换了xlrd,所以Excel文件必须为.xls而不能是.xlsx,代码就不重新贴了,源码是openpyxl的,支持xlsx和xls。
四、源码:
# Copyright (c) wUw(wuwofcproject.com). All Rights Reserved.## Copyright Notice# wUw(wuwofcproject.com) copyrights this specification. No part of this specification may be reproduced in any form or means, without the prior written consent of wUw(wuwofcproject.com).## Disclaimer# This specification is preliminary and is subject to change at any time without notice. wUw(wuwofcproject.com) assumes no responsibility for any errors contained herein.import timefrom tkinter import *from tkinter import messageboxfrom tkinter import filedialogimport tkinter.font as tkFontimport tkinter.ttkimport openpyxlwindow = Tk()# 创建主窗口window.geometry('+170+0')window.attributes("-topmost",1)ft = tkFont.Font(family='SourceHanSansCN-Bold',size=8)window.title('倒数计划')# 窗口命名为归档工具window.geometry('1640x50')#设置窗口为720*480'''screenWidth = window.winfo_screenwidth() # 获取显示区域的宽度screenHeight = window.winfo_screenheight() # 获取显示区域的高度width = 1920 # 设定窗口宽度height = 50 # 设定窗口高度left = 0top = 0'''window.resizable(width=False, height=False)window.iconbitmap('clocklogo.ico')# 更改窗口图标window.attributes("-alpha",0.9)# 窗口透明度varF_2 = StringVar()LF_2 = Label(window,text = "计划表:",font=ft).place(relx = 0,height=20,rely = 0)EnF_2 = Entry(window, textvariable = varF_2).place(relx = 0.05,width =800,height=20,rely = 0.04)btn = Button(window,text = "开始倒数",font=ft,command = lambda:[amendmentll()]).place(relx = 0.61,height=25,width = 80,rely = 0)btn1 = Button(window,text = "开始计划",font=ft,command = lambda:[amendmentll1()]).place(relx = 0.665,height=25,width = 80,rely = 0)def select_folder1():selected_folder1 = filedialog.askopenfilename() # 使用askopenfilename函数选择单个文件夹varF_2.set(selected_folder1)Button(window, text="选择文件", command=select_folder1,font=ft).place(relx =0.55,height=25,width = 80,rely = 0)progressbarOne = tkinter.ttk.Progressbar(window)progressbarOne.place(relx=0.01, width=1610, height=5, rely=0.6)progressbartwo = tkinter.ttk.Progressbar(window)progressbartwo.place(relx=0.01, width=1610, height=5, rely=0.8)Label(window, text="进行阶段:",font=ft).place(relx=0.8, height=20, rely=0)def amendmentll():starttime = varF_2.get()timearray = time.strptime(starttime, '%Y-%m-%d %H:%M:%S')timeStamp = time.mktime(timearray)progressbarOne['maximum'] = (abs(int(time.time() - timeStamp))) # 进度值最大值progressbarOne['value'] = 0 # 进度值初始值while time.time() <= timeStamp:timearray = time.strptime(starttime, '%Y-%m-%d %H:%M:%S')timeStamp = time.mktime(timearray)timearray2 = time.time() - timeStamptimeone = (abs(int(timearray2)))print(timeone)time.sleep(1)progressbarOne['value'] += 1 # 进度条+1window.update()messagebox.showinfo('警告', '倒计时完成')def amendmentll1():workbook = openpyxl.load_workbook(varF_2.get())#print(varF_2.get())sheet = workbook['Sheet1']list1 = ([])list2 = ([])num = 1num1 = 1while num <= int(str(sheet.max_row)):a = sheet.cell(row=num, column=1).valuelist1.append(a)num +=1while num1 <= int(str(sheet.max_row)):a = sheet.cell(row=num1, column=2).valuelist2.append(a)num1 +=1del list1[0]del list2[0]progressbartwo['maximum'] = len(list1) # 进度值最大值progressbartwo['value'] = 0 # 进度值初始值num2 = 0while num2 <= len(list1)-1:starttime = list1[num2]print(list1[num2])timearray = time.strptime(starttime, '%Y-%m-%d %H:%M:%S')timeStamp = time.mktime(timearray)progressbarOne['maximum'] = (abs(int(time.time() - timeStamp))) # 进度值最大值progressbarOne['value'] = 0 # 进度值初始值while time.time() <= timeStamp:Label(window, text=list2[num2], font=ft).place(relx=0.85, height=20, rely=0)timearray = time.strptime(starttime, '%Y-%m-%d %H:%M:%S')timeStamp = time.mktime(timearray)timearray2 = time.time() - timeStamptimeone = (abs(int(timearray2)))print(timeone)time.sleep(1)progressbarOne['value'] += 1 # 进度条+1window.update()progressbartwo['value'] += 1 # 进度条+1window.update()num2 += 1messagebox.showinfo('警告', '倒计时完成')window.mainloop()
