当前位置:网站首页>工作任务统计
工作任务统计
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()
边栏推荐
- 告别手摇织布机的AI时代
- Byte Qiu Zhao confused me on both sides, and asked me under what circumstances would the SYN message be discarded?
- Golang学习之路(五):Golang的函数
- 1-hour live broadcast recruitment order: industry big names share dry goods, and enterprise registration opens丨qubit·viewpoint
- HAproxy: load balancing
- Shell正则表达式,三剑客之grep命令
- 数据挖掘-06
- Adalvo收购其首个品牌产品Onsolis
- WeChat side: what is consistent hashing, usage scenarios, and what problems does it solve?
- 微信小程序支付及退款整体流程
猜你喜欢
随机推荐
使用注解将EventBus封装抽取到基类
Two minutes recording can pass by second language!The volcano how to practice and become voice tone reproduction technology?
曼城推出可检测情绪的智能围巾,把球迷给整迷惑了
超越CLIP的多模态模型,只需不到1%的训练数据!南加大最新研究来了
Apexsqlrecover cannot connect to database
WeChat Mini Program Payment and Refund Overall Process
ABAP 面试题:如何使用 ABAP 编程语言的 System CALL 接口,直接执行 ABAP 服务器所在操作系统的 shell 命令?
Fragment中嵌套ViewPager数据空白页异常问题分析
Flutter入门进阶之旅(四)文本输入Widget TextField
Simple understanding of ThreadLocal
FFmpeg在win10上编译安装(配置libx264)
The redis library cannot be imported
又有大厂员工连续加班倒下/ 百度搜狗取消快照/ 马斯克生父不为他骄傲...今日更多新鲜事在此...
Flutter Getting Started and Advanced Tour (3) Text Widgets
报告:想学AI的学生数量已涨200%,老师都不够用了
Scala 高阶(七):集合内容汇总(上篇)
放下手机吧:实验表明花20分钟思考和上网冲浪同样快乐
阻塞、非阻塞、多路复用、同步、异步、BIO、NIO、AIO 一锅端
数据挖掘-06
Manchester city launch emotional intelligence scarf can be detected, give the fans








