一个电销工作日志生成系统

11次阅读
没有评论

### 功能简介此代码是一个基于 Python 的 `tkinter` 库开发的电销业务工作日志管理软件,主要用于记录和管理日常工作相关信息,包括电销业务数据、任务管理以及客户反馈情况等,具备日志生成、查询、复制等功能,以下是详细的功能说明:1. **工作日志信息记录**:可记录每日任务、电销人员信息、呼出电话、接通电话、开单数量等多项业务数据,还能记录客户反馈情况。2. **任务管理**:支持添加、完成、删除任务,任务状态分为待办和已完成,已完成任务会显示为绿色。3. **日志生成与保存**:能根据当日记录的信息生成工作日志文件,并保存到指定目录。4. **往日日志查询**:可查询并查看往日的工作日志内容。5. **当日日志操作**:支持复制和查看当日工作日志内容。6. **界面自适应**:界面元素会根据窗口大小自动调整字体和布局。

[Python] 纯文本查看 复制代码

import tkinter as tk
from tkinter import ttk, messagebox
import datetime
import json
import os
import shutil
import pyperclip # 用于复制文本到剪贴板
class WorkLogApp:
def __init__(self, root):
self.root = root
self.root.title("XX业务工作日志")
# 尝试加载之前保存的窗口尺寸
self.load_window_size()
# 主色调,使用蓝色代表信任
self.primary_color = "#007BFF"
self.secondary_color = "#6C757D"
self.neutral_color = "#F8F9FA"
# 调整窗口背景色为中性色
self.root.configure(bg=self.neutral_color)
self.root.rowconfigure(0, weight=1)
self.root.columnconfigure(0, weight=1)
self.tasks = []
self.completed = []
self.load_tasks()
self.style = ttk.Style()
self.style.theme_use("clam")
self.base_font_size = 12
self.label_font_size = 14
self.min_font_size = 8
# 统一使用现代无衬线字体
self.font_family = "Inter"
# 主框架使用 grid 布局
main_frame = ttk.Frame(root, style="MainFrame.TFrame")
main_frame.grid(row=0, column=0, sticky="nsew", padx=20, pady=20)
main_frame.rowconfigure(0, weight=1)
main_frame.rowconfigure(1, weight=1)
main_frame.rowconfigure(2, weight=0)
main_frame.columnconfigure(0, weight=1)
self.create_log_section(main_frame)
self.create_task_section(main_frame)
button_frame = ttk.Frame(main_frame, style="ButtonFrame.TFrame")
button_frame.grid(row=2, column=0, sticky="ew", pady=20) # 增加按钮框架的垂直间距
self.query_button = self.create_query_button(button_frame)
self.copy_button = self.create_copy_button(button_frame)
self.view_today_button = self.create_view_today_button(button_frame)
# 将 update_font_sizes 调用移到 create_task_section 之后
self.update_font_sizes()
try:
self.reset_tasks_daily()
except PermissionError:
messagebox.showerror("错误", "没有权限访问或修改 last_date.txt 文件,请检查文件权限。")
self.load_today_log()
self.root.bind("<Configure>", self.on_window_resize)
self.root.protocol("WM_DELETE_WINDOW", self.on_close)
def load_window_size(self):
try:
if os.path.exists("window_size.json"):
with open("window_size.json", "r", encoding="utf-8") as f:
data = json.load(f)
width = data.get("width", 1200)
height = data.get("height", 1000)
self.root.geometry(f"{width}x{height}")
else:
self.root.geometry("1200x1000")
except Exception as e:
messagebox.showerror("错误", f"加载窗口尺寸失败: {str(e)}")
self.root.geometry("1200x1000")
def save_window_size(self):
try:
width = self.root.winfo_width()
height = self.root.winfo_height()
with open("window_size.json", "w", encoding="utf-8") as f:
json.dump({"width": width, "height": height}, f)
except Exception as e:
messagebox.showerror("错误", f"保存窗口尺寸失败: {str(e)}")
def on_close(self):
self.save_window_size()
self.root.destroy()
def update_font_sizes(self):
width = self.root.winfo_width()
height = self.root.winfo_height()
scale_factor = min(width / 1200, height / 1000)
font_size = int(self.base_font_size * scale_factor)
label_font_size = int(self.label_font_size * scale_factor)
font_size = max(font_size, self.min_font_size)
label_font_size = max(label_font_size, self.min_font_size)
# 使用 ttk 样式来配置背景颜色
self.style.configure("MainFrame.TFrame", padding=10 * scale_factor, background=self.neutral_color, borderwidth=0, relief=tk.FLAT)
self.style.configure("ButtonFrame.TFrame", padding=10 * scale_factor, background=self.neutral_color, borderwidth=0, relief=tk.FLAT)
self.style.configure("TButton", padding=(10 * scale_factor, 5 * scale_factor), font=(self.font_family, font_size), foreground="white", background=self.primary_color, borderwidth=0, relief=tk.FLAT, borderradius=5)
self.style.map("TButton", background=[('active', '#0056b3'), ('hover', '#0069d9')]) # 按钮悬停效果
self.style.configure("TEntry", padding=8 * scale_factor, font=(self.font_family, font_size), fieldbackground="white", borderwidth=1, relief=tk.SOLID, highlightbackground=self.secondary_color, highlightcolor=self.secondary_color, highlightthickness=1, borderradius=5) # 使用 highlight 替代 bordercolor
self.style.configure("TLabelframe", background=self.neutral_color, font=(self.font_family, label_font_size, "bold"), labeloutside=False, borderwidth=2, relief=tk.GROOVE, highlightbackground=self.secondary_color, highlightcolor=self.secondary_color, highlightthickness=1, borderradius=5) # 使用 highlight 替代 bordercolor
self.style.configure("TLabelframe.Label", background=self.neutral_color, font=(self.font_family, label_font_size, "bold"))
self.style.configure("TLabel", background=self.neutral_color, font=(self.font_family, font_size))
self.style.configure("Vertical.TScrollbar", troughcolor=self.neutral_color, gripcount=0, arrowsize=15 * scale_factor, borderwidth=0, relief=tk.FLAT)
# 调整输入框和按钮的宽度
entry_width = int(20 * scale_factor)
button_width = int(30 * scale_factor)
for entry in self.log_info_entries.values():
entry.configure(width=entry_width)
self.daily_task_entry.configure(width=entry_width)
self.task_entry.configure(width=int(50 * scale_factor))
self.query_button.configure(width=button_width)
self.copy_button.configure(width=button_width)
self.view_today_button.configure(width=button_width)
self.daily_task_button.configure(width=button_width)
self.add_task_button.configure(width=button_width)
self.complete_task_button.configure(width=button_width)
self.delete_task_button.configure(width=button_width)
self.generate_log_button.configure(width=button_width)
def on_window_resize(self, event):
self.update_font_sizes()
self.update_button_sizes()
def update_button_sizes(self):
width = self.root.winfo_width()
height = self.root.winfo_height()
scale_factor = min(width / 1200, height / 1000)
button_width = int(30 * scale_factor)
button_height = int(3 * scale_factor)
self.query_button.configure(width=button_width)
self.copy_button.configure(width=button_width)
self.view_today_button.configure(width=button_width)
self.style.configure("TButton", padding=(10 * scale_factor, 5 * scale_factor))
def create_log_section(self, parent):
frame = ttk.LabelFrame(parent, text="工作日志信息", style="TLabelframe")
frame.grid(row=0, column=0, sticky="nsew", padx=20, pady=20) # 增加框架的内外间距
frame.rowconfigure(0, weight=1)
frame.rowconfigure(1, weight=1)
frame.columnconfigure(0, weight=1)
# 添加阴影效果
frame.configure(style="Shadow.TLabelframe")
# 每日任务分组
daily_task_frame = ttk.Frame(frame, style="TFrame")
daily_task_frame.grid(row=0, column=0, sticky="ew", padx=10, pady=10) # 增加分组的垂直间距
daily_task_label = ttk.Label(daily_task_frame, text="每日任务", style="TLabel")
daily_task_label.pack(side=tk.LEFT, padx=10)
self.daily_task_entry = ttk.Entry(daily_task_frame, width=20, style="TEntry")
self.daily_task_entry.pack(side=tk.LEFT, padx=10)
self.daily_task_status = tk.StringVar()
self.daily_task_status.set("未完成")
self.daily_task_button = ttk.Button(daily_task_frame, textvariable=self.daily_task_status, command=self.toggle_daily_task_status, style="TButton")
self.daily_task_button.pack(side=tk.LEFT, padx=10)
# 其他日志信息分组
log_info_frame = ttk.Frame(frame, style="TFrame")
log_info_frame.grid(row=1, column=0, sticky="nsew", padx=10, pady=10) # 增加分组的垂直间距
log_info_frame.rowconfigure(0, weight=1)
log_info_frame.columnconfigure(0, weight=1)
log_info_labels = [
"电销人员", "呼出电话", "接通电话", "30s以上通话个数",
"添加微信", "开单数量", "销售金额", "意向客户",
"报价数量", "邮寄样品", "收到样品", "收到水样",
"待跟进客户", "昨天(水样/样品)"
]
self.log_info_entries = {}
for i, label_text in enumerate(log_info_labels):
label, entry = self.create_label_entry(log_info_frame, label_text, i)
if label_text in ["呼出电话", "接通电话", "30s以上通话个数",
"开单数量", "销售金额"]:
entry.config(validate="key",
validatecommand=(log_info_frame.register(self.validate_number), "%P"))
self.log_info_entries[label_text] = entry
feedback_label = ttk.Label(frame, text="客户那边反馈情况", style="TLabel")
feedback_label.grid(row=2, column=0, sticky="w", padx=10, pady=10) # 增加标签的垂直间距
self.feedback_text = tk.Text(frame, height=5, width=40, font=(self.font_family, self.base_font_size))
self.feedback_text.grid(row=3, column=0, sticky="nsew", padx=10, pady=10) # 增加文本框的垂直间距
self.feedback_text.configure(borderwidth=1, relief=tk.SOLID, highlightbackground=self.secondary_color, highlightcolor=self.secondary_color, highlightthickness=1)
def create_label_entry(self, parent, label_text, index):
row = index // 3
col = index % 3 * 2
label = ttk.Label(parent, text=label_text, style="TLabel")
label.grid(row=row, column=col, sticky=tk.W, padx=10, pady=5)
entry_width = 25 if label_text in ["30s以上通话个数", "待跟进客户"] else 20
entry = ttk.Entry(parent, width=entry_width, style="TEntry")
entry.grid(row=row, column=col + 1, sticky=tk.EW, padx=10, pady=5)
parent.columnconfigure(col + 1, weight=1)
return label, entry
def create_task_section(self, parent):
frame = ttk.LabelFrame(parent, text="任务管理", style="TLabelframe")
frame.grid(row=1, column=0, sticky="nsew", padx=20, pady=20) # 增加框架的内外间距
frame.rowconfigure(0, weight=1)
frame.rowconfigure(1, weight=1)
frame.rowconfigure(2, weight=0)
frame.columnconfigure(0, weight=1)
# 添加阴影效果
frame.configure(style="Shadow.TLabelframe")
input_frame = ttk.Frame(frame, style="TaskInputFrame.TFrame")
input_frame.grid(row=0, column=0, sticky="ew", pady=20, padx=20) # 增加输入框框架的垂直间距
self.task_entry = ttk.Entry(input_frame, width=50, style="TEntry")
self.task_entry.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=10)
self.task_entry.bind("<Return>", lambda e: self.add_task())
self.add_task_button = ttk.Button(input_frame, text="添加任务", command=self.add_task, style="TButton")
self.add_task_button.pack(side=tk.LEFT, padx=20)
list_frame = ttk.Frame(frame, style="TaskListFrame.TFrame")
list_frame.grid(row=1, column=0, sticky="nsew", padx=20, pady=20) # 增加列表框框架的垂直间距
# 缩小任务输出栏高度
self.task_listbox = tk.Listbox(
list_frame,
width=60,
height=4, # 原高度为 8,现缩小为 4
selectmode=tk.SINGLE,
bg="white",
font=(self.font_family, self.base_font_size),
borderwidth=1,
relief=tk.SOLID,
highlightbackground=self.secondary_color,
highlightcolor=self.secondary_color,
highlightthickness=1
)
self.task_listbox.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
scrollbar = ttk.Scrollbar(list_frame, orient=tk.VERTICAL, style="Vertical.TScrollbar")
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
self.task_listbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.task_listbox.yview)
btn_frame = ttk.Frame(frame, style="TaskButtonFrame.TFrame")
btn_frame.grid(row=2, column=0, sticky="nsew", pady=20, padx=20) # 增加按钮框架的垂直间距
btn_frame.columnconfigure(0, weight=1)
btn_frame.columnconfigure(1, weight=1)
btn_frame.columnconfigure(2, weight=1)
self.complete_task_button = ttk.Button(btn_frame, text="完成任务", command=self.complete_task, style="TButton")
self.complete_task_button.grid(row=0, column=0, padx=10, pady=10, sticky="ew")
self.delete_task_button = ttk.Button(btn_frame, text="删除任务", command=self.delete_task, style="TButton")
self.delete_task_button.grid(row=0, column=1, padx=10, pady=10, sticky="ew")
self.generate_log_button = ttk.Button(btn_frame, text="生成日志", command=self.generate_log, style="TButton")
self.generate_log_button.grid(row=0, column=2, padx=10, pady=10, sticky="ew")
self.refresh_task_list()
def create_query_button(self, parent):
# 使用 FontAwesome 图标
icon = ttk.Label(parent, text="\uf002", font=("FontAwesome", 12))
icon.pack(side=tk.LEFT, padx=5)
query_button = ttk.Button(parent, text="查询往日日志", command=self.query_past_logs, style="TButton")
query_button.pack(side=tk.LEFT, padx=10, expand=True)
# 添加提示信息
query_button.bind("<Enter>", lambda e: self.show_tooltip(query_button, "点击查询往日的工作日志"))
query_button.bind("<Leave>", lambda e: self.hide_tooltip())
return query_button
def create_copy_button(self, parent):
icon = ttk.Label(parent, text="\uf0c5", font=("FontAwesome", 12))
icon.pack(side=tk.LEFT, padx=5)
copy_button = ttk.Button(parent, text="复制当日工作日志", command=self.copy_today_log, style="TButton")
copy_button.pack(side=tk.LEFT, padx=10, expand=True)
copy_button.bind("<Enter>", lambda e: self.show_tooltip(copy_button, "点击复制当日的工作日志内容"))
copy_button.bind("<Leave>", lambda e: self.hide_tooltip())
return copy_button
def create_view_today_button(self, parent):
icon = ttk.Label(parent, text="\uf06e", font=("FontAwesome", 12))
icon.pack(side=tk.LEFT, padx=5)
view_today_button = ttk.Button(parent, text="查看当日日志", command=self.view_today_log, style="TButton")
view_today_button.pack(side=tk.LEFT, padx=10, expand=True)
view_today_button.bind("<Enter>", lambda e: self.show_tooltip(view_today_button, "点击查看当日的工作日志"))
view_today_button.bind("<Leave>", lambda e: self.hide_tooltip())
return view_today_button
def validate_number(self, value):
if value == "" or value.isdigit():
return True
return False
def load_tasks(self):
try:
if os.path.exists("tasks.json"):
with open("tasks.json", "r", encoding="utf-8") as f:
data = json.load(f)
self.tasks = data["tasks"]
self.completed = data["completed"]
except FileNotFoundError:
messagebox.showinfo("提示", "未找到任务保存文件,将使用新的任务列表。")
except json.JSONDecodeError:
messagebox.showerror("错误", "任务保存文件格式错误,无法加载。")
except Exception as e:
messagebox.showerror("错误", f"加载任务失败: {str(e)}")
def save_tasks(self):
try:
with open("tasks.json", "w", encoding="utf-8") as f:
json.dump({
"tasks": self.tasks,
"completed": self.completed
}, f, ensure_ascii=False)
messagebox.showinfo("提示", "任务保存成功。")
except PermissionError:
messagebox.showerror("错误", "没有权限保存任务文件,请检查文件权限。")
except Exception as e:
messagebox.showerror("错误", f"保存任务失败: {str(e)}")
def refresh_task_list(self):
self.task_listbox.delete(0, tk.END)
for task, status in zip(self.tasks, self.completed):
prefix = "[完成] " if status else "[待办] "
self.task_listbox.insert(tk.END, prefix + task)
if status:
self.task_listbox.itemconfig(tk.END, {'fg': 'green'})
def add_task(self):
task = self.task_entry.get().strip()
if task:
self.tasks.append(task)
self.completed.append(False)
index = len(self.tasks) - 1
prefix = "[待办] "
self.task_listbox.insert(tk.END, prefix + task)
self.task_listbox.itemconfig(tk.END, {'fg': 'black'})
self.fade_in(index)
self.task_entry.delete(0, tk.END)
self.save_tasks()
else:
messagebox.showwarning("警告", "请输入任务内容!")
def fade_in(self, index, alpha=0):
if alpha < 1:
alpha += 0.1
self.task_listbox.itemconfig(index, {'fg': f'rgba(0, 0, 0, {alpha})'})
self.root.after(30, self.fade_in, index, alpha)
def complete_task(self):
selected_index = self.task_listbox.curselection()
if selected_index:
index = selected_index[0]
self.completed[index] = True
task = self.tasks[index]
self.task_listbox.delete(index)
self.task_listbox.insert(index, "[完成] " + task)
self.task_listbox.itemconfig(index, {'fg': 'green'})
self.save_tasks()
else:
messagebox.showwarning("警告", "请选择要完成的任务!")
def fade_out(self, index, alpha=1):
if alpha > 0:
alpha -= 0.1
self.task_listbox.itemconfig(index, {'fg': f'rgba(0, 128, 0, {alpha})'})
self.root.after(30, self.fade_out, index, alpha)
else:
self.refresh_task_list()
self.save_tasks()
def generate_log(self):
today = datetime.datetime.now().strftime("%Y年%m月%d日")
log_dir = "工作日志"
try:
if not os.path.exists(log_dir):
os.makedirs(log_dir)
messagebox.showinfo("提示", "正在生成日志,请稍候...")
log_content = self._generate_log_content(today)
file_path = os.path.join(log_dir, f"{today}_工作日志.txt")
with open(file_path, "w", encoding="utf-8") as f:
f.write(log_content)
messagebox.showinfo("成功", f"日志已保存到:\n{file_path}")
except PermissionError:
messagebox.showerror("错误", "没有权限创建日志目录或保存文件,请检查文件权限。")
except Exception as e:
messagebox.showerror("错误", f"保存失败:{str(e)}")
def _generate_log_content(self, date):
log = f"{date}\n"
daily_task = self.daily_task_entry.get().strip()
if daily_task:
status = "完成" if self.daily_task_status.get() == "完成" else "未完成"
log += f"每日任务:{daily_task}({status})\n"
log += "\n"
log += f"电销人员:{self.log_info_entries['电销人员'].get().strip()}\n"
log += f"呼出电话:{self.log_info_entries['呼出电话'].get().strip()}\n"
log += f"接通电话:{self.log_info_entries['接通电话'].get().strip()}\n"
log += f"30s以上通话个数:{self.log_info_entries['30s以上通话个数'].get().strip()}\n"
log += f"添加微信:{self.log_info_entries['添加微信'].get().strip()}\n"
log += f"开单数量:{self.log_info_entries['开单数量'].get().strip()}\n"
log += f"销售金额:{self.log_info_entries['销售金额'].get().strip()}\n"
log += f"意向客户:{self.log_info_entries['意向客户'].get().strip()}\n"
log += f"报价数量:{self.log_info_entries['报价数量'].get().strip()}\n"
log += f"邮寄样品:{self.log_info_entries['邮寄样品'].get().strip()}\n"
log += f"收到样品:{self.log_info_entries['收到样品'].get().strip()}\n"
log += f"收到水样:{self.log_info_entries['收到水样'].get().strip()}\n"
log += f"待跟进客户:{self.log_info_entries['待跟进客户'].get().strip()}\n"
log += f"昨天(水样/样品):{self.log_info_entries['昨天(水样/样品)'].get().strip()}\n"
feedback = self.feedback_text.get("1.0", tk.END).strip()
if feedback:
log += "\n客户那边反馈情况 :\n"
log += feedback.replace("\n", "\n2. " if feedback.count("\n") > 0 else "")
if feedback.count("\n") > 0:
log = log.replace("2. ", "1. ", 1)
log += "\n客户资料表已转发财务XX"
return log
def query_past_logs(self):
log_dir = "工作日志"
if not os.path.exists(log_dir):
messagebox.showinfo("提示", "暂无往日日志。")
return
log_files = [f for f in os.listdir(log_dir) if f.endswith("_工作日志.txt")]
if not log_files:
messagebox.showinfo("提示", "暂无往日日志。")
return
query_window = tk.Toplevel(self.root)
query_window.title("往日日志查询")
query_window.geometry("600x400")
query_window.configure(bg=self.neutral_color)
log_listbox = tk.Listbox(query_window)
log_listbox.pack(fill=tk.BOTH, expand=True, padx=20, pady=20)
for log_file in log_files:
log_listbox.insert(tk.END, log_file)
def show_log_content(event):
selected_index = log_listbox.curselection()
if selected_index:
selected_file = log_listbox.get(selected_index)
file_path = os.path.join(log_dir, selected_file)
try:
with open(file_path, "r", encoding="utf-8") as f:
log_content = f.read()
content_window = tk.Toplevel(query_window)
content_window.title(selected_file)
content_window.geometry("600x400")
content_window.configure(bg=self.neutral_color)
text = tk.Text(content_window, wrap=tk.WORD)
text.insert(tk.END, log_content)
text.config(state=tk.DISABLED)
text.pack(fill=tk.BOTH, expand=True, padx=20, pady=20)
except Exception as e:
messagebox.showerror("错误", f"读取日志文件失败: {str(e)}")
log_listbox.bind("<<ListboxSelect>>", show_log_content)
def reset_tasks_daily(self):
today = datetime.datetime.now().strftime("%Y%m%d")
try:
if os.path.exists("last_date.txt"):
with open("last_date.txt", "r") as f:
last_date = f.read().strip()
if last_date != today:
self.tasks = []
self.completed = []
self.save_tasks()
with open("last_date.txt", "w") as f:
f.write(today)
except PermissionError:
raise
def copy_today_log(self):
today = datetime.datetime.now().strftime("%Y年%m月%d日")
log_dir = "工作日志"
file_path = os.path.join(log_dir, f"{today}_工作日志.txt")
if os.path.exists(file_path):
try:
with open(file_path, "r", encoding="utf-8") as f:
log_content = f.read()
pyperclip.copy(log_content)
messagebox.showinfo("成功", "当日日志文本内容已复制到剪贴板。")
except Exception as e:
messagebox.showerror("错误", f"复制日志内容失败: {str(e)}")
else:
messagebox.showinfo("提示", "当日日志尚未生成,请先生成日志。")
def view_today_log(self):
today = datetime.datetime.now().strftime("%Y年%m月%d日")
log_dir = "工作日志"
file_path = os.path.join(log_dir, f"{today}_工作日志.txt")
if os.path.exists(file_path):
try:
with open(file_path, "r", encoding="utf-8") as f:
log_content = f.read()
content_window = tk.Toplevel(self.root)
content_window.title(f"{today} 工作日志")
content_window.geometry("600x400")
content_window.configure(bg=self.neutral_color)
text = tk.Text(content_window, wrap=tk.WORD)
text.insert(tk.END, log_content)
text.config(state=tk.DISABLED)
text.pack(fill=tk.BOTH, expand=True, padx=20, pady=20)
except Exception as e:
messagebox.showerror("错误", f"读取日志文件失败: {str(e)}")
else:
messagebox.showinfo("提示", "当日日志尚未生成,请先生成日志。")
def load_today_log(self):
today = datetime.datetime.now().strftime("%Y年%m月%d日")
log_dir = "工作日志"
file_path = os.path.join(log_dir, f"{today}_工作日志.txt")
if os.path.exists(file_path):
try:
with open(file_path, "r", encoding="utf-8") as f:
log_content = f.read()
lines = log_content.splitlines()
for line in lines:
if "每日任务:" in line:
task = line.split("每日任务:")[1].split("(")[0]
status = line.split("(")[1].split(")")[0]
self.daily_task_entry.delete(0, tk.END)
self.daily_task_entry.insert(0, task)
self.daily_task_status.set(status)
elif ":" in line:
label, value = line.split(":", 1)
if label in self.log_info_entries:
self.log_info_entries[label].delete(0, tk.END)
self.log_info_entries[label].insert(0, value)
elif "客户那边反馈情况 :" in line:
start_index = lines.index(line) + 1
feedback_lines = []
while start_index < len(lines) and lines[start_index].strip():
feedback_lines.append(lines[start_index])
feedback = "\n".join(feedback_lines)
self.feedback_text.delete("1.0", tk.END)
self.feedback_text.insert(tk.END, feedback)
except Exception as e:
messagebox.showerror("错误", f"加载当日日志失败: {str(e)}")
def delete_task(self):
selected_index = self.task_listbox.curselection()
if selected_index:
index = selected_index[0]
del self.tasks[index]
del self.completed[index]
self.task_listbox.delete(index)
self.save_tasks()
else:
messagebox.showwarning("警告", "请选择要删除的任务!")
def toggle_daily_task_status(self):
if self.daily_task_status.get() == "未完成":
self.daily_task_status.set("完成")
else:
self.daily_task_status.set("未完成")
def show_tooltip(self, widget, text):
self.tooltip = tk.Toplevel(widget)
self.tooltip.wm_overrideredirect(True)
self.tooltip.wm_geometry(f"+{widget.winfo_rootx()}+{widget.winfo_rooty() + widget.winfo_height()}")
label = tk.Label(self.tooltip, text=text, background="#ffffff", relief=tk.SOLID, borderwidth=1)
label.pack()
def hide_tooltip(self):
if hasattr(self, 'tooltip'):
self.tooltip.destroy()

if __name__ == "__main__":
root = tk.Tk()
app = WorkLogApp(root)
root.mainloop()

### 使用引导#### 1. 运行环境此代码需在 Python 3.9 及以上版本中运行,同时要安装 `pyperclip` 库,可使用以下命令安装:```bashpip install pyperclip```#### 2. 运行代码将上述代码保存为一个 Python 文件(例如 `work_log_app.py`),在命令行中运行以下命令:```bashpython work_log_app.py```#### 3. 界面操作说明- **工作日志信息填写** - **每日任务**:在“每日任务”输入框中输入任务内容,点击“未完成”按钮可切换任务状态。 - **其他信息**:在对应的输入框中输入电销人员、呼出电话等业务数据。 - **客户反馈情况**:在“客户那边反馈情况”文本框中输入客户反馈内容,每行一条反馈。- **任务管理** - **添加任务**:在“任务管理”的输入框中输入任务内容,点击“添加任务”按钮或按下回车键添加任务。 - **完成任务**:在任务列表中选择要完成的任务,点击“完成任务”按钮。 - **删除任务**:在任务列表中选择要删除的任务,点击“删除任务”按钮。- **日志操作** - **生成日志**:点击“生成日志”按钮,会在“工作日志”目录下生成当日的工作日志文件。 - **查询往日日志**:点击“查询往日日志”按钮,可查看往日的工作日志列表,点击列表中的日志文件可查看详细内容。 - **复制当日日志**:点击“复制当日工作日志”按钮,可将当日的工作日志内容复制到剪贴板。 - **查看当日日志**:点击“查看当日日志”按钮,可查看当日的工作日志内容。#### 4. 注意事项- 若“工作日志”目录不存在,软件会自动创建该目录。- 每日任务和任务列表会在每天自动重置。- 若重新打开软件,会自动加载当日已保存的日志信息。

正文完
 0
116博客
版权声明:本篇文章由 116博客 于2025-04-02发表,共计20765字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码