一、功能介绍:

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格式文件。
原始截图.png

二、演示:

模式一:
模式1.gif
模式二:
模式2.gif

三、程序包:

clock.dist.rar
最终还是为了小一些,更换了xlrd,所以Excel文件必须为.xls而不能是.xlsx,代码就不重新贴了,源码是openpyxl的,支持xlsx和xls。

四、源码:

  1. # Copyright (c) wUw(wuwofcproject.com). All Rights Reserved.
  2. #
  3. # Copyright Notice
  4. # 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).
  5. #
  6. # Disclaimer
  7. # 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.
  8. import time
  9. from tkinter import *
  10. from tkinter import messagebox
  11. from tkinter import filedialog
  12. import tkinter.font as tkFont
  13. import tkinter.ttk
  14. import openpyxl
  15. window = Tk()# 创建主窗口
  16. window.geometry('+170+0')
  17. window.attributes("-topmost",1)
  18. ft = tkFont.Font(family='SourceHanSansCN-Bold',size=8)
  19. window.title('倒数计划')# 窗口命名为归档工具
  20. window.geometry('1640x50')#设置窗口为720*480
  21. '''screenWidth = window.winfo_screenwidth() # 获取显示区域的宽度
  22. screenHeight = window.winfo_screenheight() # 获取显示区域的高度
  23. width = 1920 # 设定窗口宽度
  24. height = 50 # 设定窗口高度
  25. left = 0
  26. top = 0'''
  27. window.resizable(width=False, height=False)
  28. window.iconbitmap('clocklogo.ico')# 更改窗口图标
  29. window.attributes("-alpha",0.9)# 窗口透明度
  30. varF_2 = StringVar()
  31. LF_2 = Label(window,text = "计划表:",font=ft).place(relx = 0,height=20,rely = 0)
  32. EnF_2 = Entry(window, textvariable = varF_2).place(relx = 0.05,width =800,height=20,rely = 0.04)
  33. btn = Button(window,text = "开始倒数",font=ft,command = lambda:[amendmentll()]).place(relx = 0.61,height=25,width = 80,rely = 0)
  34. btn1 = Button(window,text = "开始计划",font=ft,command = lambda:[amendmentll1()]).place(relx = 0.665,height=25,width = 80,rely = 0)
  35. def select_folder1():
  36. selected_folder1 = filedialog.askopenfilename() # 使用askopenfilename函数选择单个文件夹
  37. varF_2.set(selected_folder1)
  38. Button(window, text="选择文件", command=select_folder1,font=ft).place(relx =0.55,height=25,width = 80,rely = 0)
  39. progressbarOne = tkinter.ttk.Progressbar(window)
  40. progressbarOne.place(relx=0.01, width=1610, height=5, rely=0.6)
  41. progressbartwo = tkinter.ttk.Progressbar(window)
  42. progressbartwo.place(relx=0.01, width=1610, height=5, rely=0.8)
  43. Label(window, text="进行阶段:",font=ft).place(relx=0.8, height=20, rely=0)
  44. def amendmentll():
  45. starttime = varF_2.get()
  46. timearray = time.strptime(starttime, '%Y-%m-%d %H:%M:%S')
  47. timeStamp = time.mktime(timearray)
  48. progressbarOne['maximum'] = (abs(int(time.time() - timeStamp))) # 进度值最大值
  49. progressbarOne['value'] = 0 # 进度值初始值
  50. while time.time() <= timeStamp:
  51. timearray = time.strptime(starttime, '%Y-%m-%d %H:%M:%S')
  52. timeStamp = time.mktime(timearray)
  53. timearray2 = time.time() - timeStamp
  54. timeone = (abs(int(timearray2)))
  55. print(timeone)
  56. time.sleep(1)
  57. progressbarOne['value'] += 1 # 进度条+1
  58. window.update()
  59. messagebox.showinfo('警告', '倒计时完成')
  60. def amendmentll1():
  61. workbook = openpyxl.load_workbook(varF_2.get())
  62. #print(varF_2.get())
  63. sheet = workbook['Sheet1']
  64. list1 = ([])
  65. list2 = ([])
  66. num = 1
  67. num1 = 1
  68. while num <= int(str(sheet.max_row)):
  69. a = sheet.cell(row=num, column=1).value
  70. list1.append(a)
  71. num +=1
  72. while num1 <= int(str(sheet.max_row)):
  73. a = sheet.cell(row=num1, column=2).value
  74. list2.append(a)
  75. num1 +=1
  76. del list1[0]
  77. del list2[0]
  78. progressbartwo['maximum'] = len(list1) # 进度值最大值
  79. progressbartwo['value'] = 0 # 进度值初始值
  80. num2 = 0
  81. while num2 <= len(list1)-1:
  82. starttime = list1[num2]
  83. print(list1[num2])
  84. timearray = time.strptime(starttime, '%Y-%m-%d %H:%M:%S')
  85. timeStamp = time.mktime(timearray)
  86. progressbarOne['maximum'] = (abs(int(time.time() - timeStamp))) # 进度值最大值
  87. progressbarOne['value'] = 0 # 进度值初始值
  88. while time.time() <= timeStamp:
  89. Label(window, text=list2[num2], font=ft).place(relx=0.85, height=20, rely=0)
  90. timearray = time.strptime(starttime, '%Y-%m-%d %H:%M:%S')
  91. timeStamp = time.mktime(timearray)
  92. timearray2 = time.time() - timeStamp
  93. timeone = (abs(int(timearray2)))
  94. print(timeone)
  95. time.sleep(1)
  96. progressbarOne['value'] += 1 # 进度条+1
  97. window.update()
  98. progressbartwo['value'] += 1 # 进度条+1
  99. window.update()
  100. num2 += 1
  101. messagebox.showinfo('警告', '倒计时完成')
  102. window.mainloop()