当前位置:网站首页>工作任务统计
工作任务统计
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()
边栏推荐
- Win10 compiles the x264 library (there are also generated lib files)
- 读写分离后,性能居然提升100%了呀
- 听声辨物,这是AI视觉该干的???|ECCV 2022
- The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
- 水能自发变成“消毒水”,83岁斯坦福教授:揭示冬天容易得流感的部分原因...
- 无重复字符的最长子串
- Rust从入门到精通04-数据类型
- 在北极都可以穿短袖了,温度飙升至32.5℃
- Ten minutes to teach you how to use VitePress to build and deploy a personal blog site
- We really need DApp?Really can't meet our fantasy App?
猜你喜欢
随机推荐
李开复花上千万投的缝纫机器人,团队出自大疆
放下手机吧:实验表明花20分钟思考和上网冲浪同样快乐
微信一面:一致性哈希是什么,使用场景,解决了什么问题?
8、IDEA提交代码出现: Fetch failed fatal: Could not read from remote repository
Flutter Getting Started and Advanced Tour (2) Hello Flutter
ThreadLocal的简单理解
Go-based web access parameters
Go 事,如何成为一个Gopher ,并在7天找到 Go 语言相关工作,第1篇
MySQL principle and optimization of Group By optimization techniques
ABAP interview questions: how to use the System CALL interface of the ABAP programming language, direct execution ABAP server operating System's shell command?
We really need DApp?Really can't meet our fantasy App?
AQS Synchronization Component - FutureTask Analysis and Use Cases
WebView注入Js代码实现大图自适应屏幕点击图片预览详情
LeetCode热题(11.合并两个有序链表)
GPT-3组合DALL·E,60秒内搞定游戏设定和原型动画!网友看后:这游戏想玩
Customize VIEW to realize in-app message reminder to rotate up and down
1-hour live broadcast recruitment order: industry big names share dry goods, and enterprise registration opens丨qubit·viewpoint
香港服务器如何进行加密?
Manchester city launch emotional intelligence scarf can be detected, give the fans
ABP 6.0.0-rc.1的新特性