当前位置:网站首页>工作任务统计
工作任务统计
2022-08-09 12:11:00 【Newnotes】
机缘
提示:可以和大家分享最初成为创作者的初心
例如:
- 平时利用EXCEL文件来记录工作任务安排,但每次都而要打开文件进行查看,感觉不直观与方便,便利用python 将excel文件内容读取出来进行统计显示。每次开机自动启动,看着比较方便。
- 里面的代码都是从网络上搜索到的个个片段,没有啥效率可读性,目的就是解决问题。


import textwrap
import time,threading
import tkinter as tk
import ttkbootstrap as ttk
from random import choice
from ttkbootstrap.constants import *
import openpyxl
from tkinter import messagebox # 弹出提示框
from tkinter.scrolledtext import ScrolledText
def datastatistics(): #excel文件数据统计分析
wb = openpyxl.load_workbook('工作任务统计.xlsx')
# 获取workbook中所有的表格
# sheets = wb.get_sheet_names()
sheets = wb.sheetnames
# print(sheets)
# 循环遍历所有sheet
未完成任务 = []
已完成任务 = []
未完成任务计数 = 0
未完成任务分类计数 = []
已完成任务计数 = 0
已完成任务分类计数 = []
for i in range(len(sheets)):
sheet = wb.get_sheet_by_name(sheets[i])
# print('\n\n第' + str(i + 1) + '个sheet: ' + sheet.title + '->>>')
for r in range(1, sheet.max_row + 1):
if sheet.cell(row=r, column=10).value == "否":
未完成任务计数 = 未完成任务计数 + 1
# 未完成任务分类计数[sheet.title] =未完成任务计数+1
未完成任务分类计数.append(sheet.title)
未完成任务.append(sheet.cell(row=r, column=3).value)
# 未完成任务分类计数.append(未完成任务计数+1)
if sheet.cell(row=r, column=10).value == "是":
已完成任务计数 = 已完成任务计数 + 1
已完成任务分类计数.append(sheet.title)
已完成任务.append(sheet.cell(row=r, column=3).value)
总任务数 = 未完成任务计数 + 已完成任务计数
print("总任务数: " + str(总任务数))
print(未完成任务)
print(已完成任务)
# print(未完成任务计数)
# print(已完成任务计数)
每个人完成任务计数 = {}
每个人未完成任务计数 = {}
for i in range(len(sheets)):
sheet = wb.get_sheet_by_name(sheets[i])
每个人完成任务计数.update({sheets[i]: 已完成任务分类计数.count(sheets[i])})
每个人未完成任务计数.update({sheets[i]: 未完成任务分类计数.count(sheets[i])})
for x, y in 每个人完成任务计数.items(): # 通过使用 items() 函数遍历键和值:
print(x, y)
for x, y in 每个人未完成任务计数.items(): # 通过使用 items() 函数遍历键和值:
print(x, y)
return 总任务数,已完成任务计数,未完成任务计数,未完成任务,已完成任务
def create_labelframe_style(bootstyle, style):
global 函数返回数据
函数返回数据= datastatistics()
frame = ttk.Frame(root, padding=5)
# title
title = ttk.Label(frame, text='Labelframe', anchor=tk.CENTER)
title.pack(padx=5, pady=2, fill=tk.BOTH)
ttk.Separator(frame).pack(padx=5, pady=5, fill=tk.X)
# default
lbl = ttk.Labelframe(
master=frame,
text='工作任务信息统计',
bootstyle='primary',
width=150,
height=75
)
lbl.pack(padx=5, pady=5, fill=tk.BOTH)
ttk.Label(lbl, text="总任务数:").pack(side=LEFT, anchor='nw')
ttk.Label(lbl, text=函数返回数据[0], bootstyle='success').pack(side=LEFT, anchor='nw')
ttk.Label(lbl, text="未完成任务数:").pack(side=LEFT, anchor='nw')
ttk.Label(lbl, text=函数返回数据[2], bootstyle='success').pack(side=LEFT, anchor='nw')
ttk.Label(lbl, text="已完成任务数:").pack(side=LEFT, anchor='nw')
ttk.Label(lbl, text=函数返回数据[1], bootstyle='success').pack(side=LEFT, anchor='nw')
frame1 = ttk.Frame(root, padding=5)
# title
title = ttk.Label(frame1, text='Labelframe1', anchor=tk.CENTER)
title.pack(padx=5, pady=2, fill=tk.BOTH)
ttk.Separator(frame1).pack(padx=5, pady=5, fill=tk.X)
# default secondLine.pack_propagate(0)
lbl2 = ttk.Labelframe(master=frame,text='未完成工作任务',bootstyle='primary',width=5,height=400 )
lbl2.pack_propagate(0)
lbl2.pack(padx=5, pady=5, fill=tk.BOTH)
print(len(函数返回数据[3]))
# for ss in range(len(函数返回数据[3])):
# ss=ttk.Label(lbl2, text=wrap(str(函数返回数据[3][ss])), bootstyle='success')
# ss.pack(padx=5, pady=5, fill=tk.BOTH)
scrolledText = ScrolledText(root, width=5, height=10)
scrolledText=ttk.ScrolledText(lbl2)
scrolledText.pack(padx=5, pady=5)
cb_var = []
global is_check_list
global aaff
is_check_list=[]
for i in range(len(函数返回数据[3])):
is_check_list.append(ttk.IntVar(value=0))
cb = ttk.Checkbutton(scrolledText, text=wrap(str(函数返回数据[3][i])),variable = is_check_list[-1],bootstyle='success') #tk.Checkbutton
scrolledText.window_create('end', window=cb)
scrolledText.insert('end', '\n')
scrolledText.insert('end', '────────────────────────')
scrolledText.insert('end', '\n')
cb.bind('<ButtonRelease>', aa) # 列表框绑定鼠标事件函数
return frame
def aa(self): #读取列表框所选择的内容
all_select = ""
for i in range(0, len(is_check_list)):
if is_check_list[i].get() == 1:
all_select += 函数返回数据[3][i] + " "
if all_select=="": #如果没读取到内容就重新取一次,否则就显示已读取成功数据
for i in range(0, len(is_check_list)):
if is_check_list[i].get() == 1:
all_select += 函数返回数据[3][i] + " "
else:
messagebox.showinfo("提示", "你所选择的数据是:" + all_select)
def wrap(string, lenght=18): #换行显示
return '\n'.join(textwrap.wrap(string, lenght))
def change_style():
theme = choice(style.theme_names())
style.theme_use(theme)
if __name__ == '__main__':
# create visual widget style tests
# root = ttk.Window(size=(800,600))
root = tk.Tk()
root.resizable(False, False) #窗口不可调整大小。
style = ttk.Style()
ttk.Button(text="Change Theme", command=change_style).pack(padx=10, pady=10)
create_labelframe_style('', style).pack(side=tk.LEFT)
root.mainloop()
边栏推荐
猜你喜欢

MySQL principle and optimization of Group By optimization techniques

ABAP 面试题:如何使用 ABAP 编程语言的 System CALL 接口,直接执行 ABAP 服务器所在操作系统的 shell 命令?

26. Pipeline parameter substitution command xargs

【微服务~远程调用】整合RestTemplate、WebClient、Feign

太卷了... 腾讯一面被问到内存满了,会发生什么?

系统提供的堆 VS 手动改写堆

900页数学论文证明旋转的黑洞不会爆炸,丘成桐:30多年来广义相对论首次重大突破...

The latest interview summary in 20022 brought by Ali senior engineer is too fragrant

曼城推出可检测情绪的智能围巾,把球迷给整迷惑了

ABP 6.0.0-rc.1的新特性
随机推荐
随机快排时间复杂度是N平方?
无需精子卵子子宫体外培育胚胎,Cell论文作者这番话让网友们炸了
win10编译x264库(也有生成好的lib文件)
The latest interview summary in 20022 brought by Ali senior engineer is too fragrant
ABP 6.0.0-rc.1的新特性
Nature:猪死亡1小时后,器官再次运转
Golang学习之路(五):Golang的函数
非科班AI小哥火了:他没有ML学位,却拿到DeepMind的offer
Programmer's Exclusive Romance - Use 3D Engine to Realize Fireworks in 5 Minutes
微信小程序支付及退款整体流程
报告:想学AI的学生数量已涨200%,老师都不够用了
Apexsqlrecover cannot connect to database
自定义VIEW实现应用内消息提醒上下轮播
WeChat side: what is consistent hashing, usage scenarios, and what problems does it solve?
ABAP interview questions: how to use the System CALL interface of the ABAP programming language, direct execution ABAP server operating System's shell command?
苹果Meta都在冲的Pancake技术,中国VR团队YVR竟抢先交出产品答卷
太卷了... 腾讯一面被问到内存满了,会发生什么?
WebView injects Js code to realize large image adaptive screen click image preview details
无重复字符的最长子串
内网穿透工具ngrok使用教程