├── LICENSE ├── README.md ├── tasks.txt └── todo.pyw /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 OliverMao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pyTODO 一个简单代办工具 2 | 3 | ## 简介 4 | 5 | 本工具由Python编写,安装Python环境后可直接双击`todo.pyw`运行 -------------------------------------------------------------------------------- /tasks.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OliverMao/pyTODO/6b49844b9b410164e3ef662332523efb013e7265/tasks.txt -------------------------------------------------------------------------------- /todo.pyw: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | import win32gui 3 | import win32con 4 | from tkinter import messagebox 5 | from ctypes import windll 6 | import datetime 7 | 8 | root = tk.Tk() 9 | root.title("我的代办") 10 | root.geometry("400x500") 11 | root.overrideredirect(False) # 隐藏窗口边框 12 | root.attributes("-alpha", 0.8) # 设置窗口透明度 13 | 14 | def add_task(): 15 | task = entry.get() + ' ' +str(datetime.datetime.now())[:19] 16 | if task: 17 | listbox.insert(tk.END, task) 18 | save_tasks(True) 19 | entry.delete(0, tk.END) 20 | else: 21 | messagebox.showwarning("警告", "请输入任务!") 22 | 23 | def delete_task(): 24 | try: 25 | index = listbox.curselection()[0] 26 | save_tasks(True) 27 | listbox.delete(index) 28 | except IndexError: 29 | pass 30 | 31 | def clear_tasks(): 32 | listbox.delete(0, tk.END) 33 | 34 | def save_tasks(not_show=False): 35 | tasks = listbox.get(0, tk.END) 36 | with open("tasks.txt", "w") as file: 37 | for task in tasks: 38 | file.write(task + "\n") 39 | if not_show == False: 40 | messagebox.showinfo("提示", "任务已保存!") 41 | 42 | def load_tasks(): 43 | try: 44 | with open("tasks.txt", "r") as file: 45 | tasks = file.readlines() 46 | for task in tasks: 47 | listbox.insert(tk.END, task.strip()) 48 | except FileNotFoundError: 49 | pass 50 | 51 | def set_window_topmost(): 52 | hwnd = win32gui.GetForegroundWindow() 53 | win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE) 54 | 55 | def set_window_top_not_most(): 56 | hwnd = win32gui.GetForegroundWindow() 57 | win32gui.SetWindowPos(hwnd, win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE) 58 | 59 | def set_window_not_top(): 60 | root.after(100, set_window_top_not_most) # 设置窗口置顶 61 | 62 | def set_window_top(): 63 | root.after(100, set_window_topmost) # 设置窗口置顶 64 | 65 | def hide_tabbar_icon(): 66 | hwnd = win32gui.GetForegroundWindow() 67 | 68 | # 获取窗口扩展样式 69 | style = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) 70 | 71 | # 隐藏任务栏图标 72 | style |= win32con.WS_EX_TOOLWINDOW 73 | style &= ~win32con.WS_EX_APPWINDOW 74 | 75 | # 更新窗口扩展样式 76 | win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, style) 77 | 78 | # 刷新窗口 79 | win32gui.SetWindowPos(hwnd, -1, 0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE | win32con.SWP_NOSIZE) 80 | 81 | def reset_window(root): 82 | # 销毁当前窗口 83 | root.destroy() 84 | 85 | # 在新窗口中添加组件和设置样式 86 | root = tk.Tk() 87 | root.title("我的代办") 88 | root.geometry("400x500") 89 | root.overrideredirect(False) # 隐藏窗口边框 90 | root.attributes("-alpha", 0.8) # 设置窗口透明度 91 | 92 | 93 | frame = tk.Frame(root) 94 | frame.pack(pady=20) 95 | 96 | listbox = tk.Listbox(frame, width=40, height=10) 97 | listbox = tk.Listbox(frame, width=40, height=10) 98 | 99 | # 设置Listbox的背景颜色 100 | listbox.configure(bg='lightgray') 101 | 102 | # 设置Listbox中选项的样式 103 | listbox.configure(font=('Arial', 15)) 104 | 105 | # 设置Listbox的边框样式 106 | listbox.configure(borderwidth=2, relief=tk.SOLID) 107 | 108 | # 设置Listbox的滚动条样式 109 | scrollbar = tk.Scrollbar(frame, command=listbox.yview) 110 | scrollbar.pack(side=tk.RIGHT, fill=tk.Y) 111 | 112 | listbox.pack(side=tk.LEFT, fill=tk.BOTH) 113 | listbox.configure(yscrollcommand=scrollbar.set) 114 | 115 | 116 | entry = tk.Entry(root, font=("Helvetica", 12)) 117 | entry.pack(pady=20) 118 | 119 | button_frame = tk.Frame(root) 120 | button_frame.pack(pady=20) 121 | 122 | add_button = tk.Button(button_frame, text="添加任务", command=add_task) 123 | add_button.grid(row=0, column=0) 124 | 125 | delete_button = tk.Button(button_frame, text="删除任务", command=delete_task) 126 | delete_button.grid(row=0, column=1) 127 | 128 | clear_button = tk.Button(button_frame, text="清空任务", command=clear_tasks) 129 | clear_button.grid(row=0, column=2) 130 | 131 | button_frame2 = tk.Frame(root) 132 | button_frame2.pack(pady=20) 133 | 134 | save_button = tk.Button(button_frame2, text="保存任务", command=save_tasks) 135 | save_button.grid(row=1, column=0) 136 | 137 | load_button = tk.Button(button_frame2, text="加载任务", command=load_tasks) 138 | load_button.grid(row=1, column=1) 139 | 140 | up_button = tk.Button(button_frame2, text= "置顶",command = set_window_top) 141 | up_button.grid(row=1, column=2) 142 | 143 | up_button = tk.Button(button_frame2, text= "取消置顶",command = set_window_not_top) 144 | up_button.grid(row=1, column=3) 145 | 146 | up_button = tk.Button(button_frame2, text= "隐藏桌面图标",command = hide_tabbar_icon) 147 | up_button.grid(row=1, column=4) 148 | 149 | load_tasks() 150 | 151 | 152 | 153 | frame = tk.Frame(root) 154 | frame.pack(pady=20) 155 | 156 | listbox = tk.Listbox(frame, width=40, height=10) 157 | listbox = tk.Listbox(frame, width=40, height=10) 158 | 159 | # 设置Listbox的背景颜色 160 | listbox.configure(bg='lightgray') 161 | 162 | # 设置Listbox中选项的样式 163 | listbox.configure(font=('Arial', 15)) 164 | 165 | # 设置Listbox的边框样式 166 | listbox.configure(borderwidth=2, relief=tk.SOLID) 167 | 168 | # 设置Listbox的滚动条样式 169 | scrollbar = tk.Scrollbar(frame, command=listbox.yview) 170 | scrollbar.pack(side=tk.RIGHT, fill=tk.Y) 171 | 172 | listbox.pack(side=tk.LEFT, fill=tk.BOTH) 173 | listbox.configure(yscrollcommand=scrollbar.set) 174 | 175 | 176 | entry = tk.Entry(root, font=("Helvetica", 12)) 177 | entry.pack(pady=20) 178 | 179 | button_frame = tk.Frame(root) 180 | button_frame.pack(pady=20) 181 | 182 | add_button = tk.Button(button_frame, text="添加任务", command=add_task) 183 | add_button.grid(row=0, column=0) 184 | 185 | delete_button = tk.Button(button_frame, text="删除任务", command=delete_task) 186 | delete_button.grid(row=0, column=1) 187 | 188 | clear_button = tk.Button(button_frame, text="清空任务", command=clear_tasks) 189 | clear_button.grid(row=0, column=2) 190 | 191 | button_frame2 = tk.Frame(root) 192 | button_frame2.pack(pady=20) 193 | 194 | save_button = tk.Button(button_frame2, text="保存任务", command=save_tasks) 195 | save_button.grid(row=1, column=0) 196 | 197 | load_button = tk.Button(button_frame2, text="加载任务", command=load_tasks) 198 | load_button.grid(row=1, column=1) 199 | 200 | up_button = tk.Button(button_frame2, text= "隐藏桌面图标",command = hide_tabbar_icon) 201 | up_button.grid(row=1, column=2) 202 | 203 | load_tasks() 204 | 205 | 206 | 207 | root.mainloop() 208 | --------------------------------------------------------------------------------