creating task and project management tool
creating task and project management tool
To create a task and project management tool in Python using Visual Studio Code, start by
setting up your development environment. Install Python and the Python extension for VS
Code.
Next, create a new project folder and a Python file (e.g., task_manager.py). You can structure
your application using Classes and Functions
Task Class: This class will represent a single task with attributes like title, description, and
status.
1. class Task:
2. def __init__(self, title, description):
3. self.title = title
4. self.description = description
5. self.completed = False
6.
7. def mark_completed(self):
8. self.completed = True
9.
10. def __str__(self):
11. return f"{self.title} - {'Completed' if self.completed else 'Pending'}"
1. class Project:
2. def __init__(self, name):
3. self.name = name
4. self.tasks = []
5.
6. def add_task(self, task):
7. self.tasks.append(task)
8.
9. def complete_task(self, task_title):
10. for task in self.tasks:
11. if task.title == task_title:
12. task.mark_completed()
13. break
14.
15. def show_tasks(self):
16. for task in self.tasks:
17. print(task)
Main Functionality
User Interaction: Create a simple command-line interface to interact with the user.
1. def main():
2. project_name = input("Enter the project name: ")
3. project = Project(project_name)
4.
5. while True:
6. print("\nOptions:")
7. print("1. Add Task")
8. print("2. Complete Task")
9. print("3. Show Tasks")
10. print("4. Exit")
11.
12. choice = input("Choose an option: ")
13.
14. if choice == '1':
15. title = input("Enter task title: ")
16. description = input("Enter task description: ")
17. task = Task(title, description)
18. project.add_task(task)
19. print("Task added.")
20.
21. elif choice == '2':
22. title = input("Enter the title of the task to complete: ")
23. project.complete_task(title)
24. print("Task marked as completed.")
25.
26. elif choice == '3':
27. print(f"\nTasks for project '{project.name}':")
28. project.show_tasks()
29.
30. elif choice == '4':
31. print("Exiting...")
32. break
33.
34. else:
35. print("Invalid option. Please try again.")
36.
37. if __name__ == "__main__":
38. main()
This code provides a basic structure for a task and project management tool. You can expand
its functionality by adding features like saving tasks to a file, loading tasks from a file, or
implementing a graphical user interface (GUI) using libraries like Tkinter or PyQt. You can also
enhance the application by adding features such as due dates for tasks, priority levels, and
categorization of tasks. Here’s how you can implement due dates and priority levels:
Saving Tasks to a File: Create a method in the Project class to save tasks.
1. import json
2.
3. class Project:
4. # Existing methods...
5.
6. def save_tasks(self, filename):
7. with open(filename, 'w') as file:
8. tasks_data = [{'title': task.title, 'description': task.description, 'completed':
task.completed,
9. 'due_date': task.due_date.strftime("%Y-%m-%d") if task.due_date else
None,
10. 'priority': task.priority} for task in self.tasks]
11. json.dump(tasks_data, file)
12.
13. def load_tasks(self, filename):
14. try:
15. with open(filename, 'r') as file:
16. tasks_data = json.load(file)
17. for task_data in tasks_data:
18. task = Task(task_data['title'], task_data['description'],
19. datetime.strptime(task_data['due_date'], "%Y-%m-%d") if
task_data['due_date'] else None,
20. task_data['priority'])
21. if task_data['completed']:
22. task.mark_completed()
23. self.add_task(task)
24. except FileNotFoundError:
25. print("No saved tasks found.")
Updating User Interaction: Modify the command-line interface to include options for
saving and loading tasks.
1. def main():
2. project_name = input("Enter the project name: ")
3. project = Project(project_name)
4.
5. while True:
6. print("\nOptions:")
7. print("1. Add Task")
8. print("2. Complete Task")
9. print("3. Show Tasks")
10. print("4. Save Tasks")
11. print("5. Load Tasks")
12. print("6. Exit")
13.
14. choice = input("Choose an option: ")
15.
16. if choice == '1':
17. title = input("Enter task title: ")
18. description = input("Enter task description: ")
19. due_date_input = input("Enter due date (YYYY-MM-DD) or leave blank: ")
20. due_date = datetime.strptime(due_date_input, "%Y-%m-%d") if
due_date_input else None
21. priority = input("Enter task priority (Low, Normal, High): ")
22. task = Task(title, description, due_date, priority)
23. project.add_task(task)
24. print("Task added.")
25.
26. elif choice == '2':
27. title = input("Enter the title of the task to complete: ")
28. project.complete_task(title)
29. print("Task marked as completed.")
30.
31. elif choice == '3':
32. print(f"\nTasks for project '{project.name}':")
33. project.show_tasks()
34.
35. elif choice == '4':
36. filename = input("Enter filename to save tasks: ")
37. project.save_tasks(filename)
38. print("Tasks saved.")
39.
40. elif choice == '5':
41. filename = input("Enter filename to load tasks: ")
42. project.load_tasks(filename)
43. print("Tasks loaded.")
44.
45. elif choice == '6':
46. print("Exiting...")
47. break
48.
49. else:
50. print("Invalid option. Please try again.")
This implementation allows users to save their tasks to a JSON file and load them back into
the application, providing a more robust task management experience. You can further
enhance the application by adding error handling and validation for user inputs, ensuring a
smoother user experience. You can also consider implementing a feature to filter tasks based
on their completion status or due dates. This would allow users to focus on specific tasks
more easily. Here’s how you can add filtering functionality:
This addition allows users to filter tasks based on their completion status, making it easier to
manage their workload. You can further enhance the filtering feature by allowing users to
filter tasks by due date or priority as well. This would provide a more comprehensive view of
their tasks and help them prioritize effectively.
Consider also implementing a graphical user interface (GUI) using libraries like Tkinter or
PyQt, which would make the application more user-friendly and visually appealing. A GUI
could provide buttons for adding tasks, completing tasks, and filtering, along with a display
area for showing tasks in a more organized manner. You can start by installing Tkinter, which
is included with most Python installations. Here’s a simple example of how to create a GUI for
the task and project management tool using Tkinter:
1. import tkinter as tk
2. from tkinter import messagebox, simpledialog
3. from datetime import datetime
4.
5. class Task:
6. def __init__(self, title, description, due_date=None, priority='Normal'):
7. self.title = title
8. self.description = description
9. self.completed = False
10. self.due_date = due_date
11. self.priority = priority
12.
13. def mark_completed(self):
14. self.completed = True
15.
16. def __str__(self):
17. due_date_str = self.due_date.strftime("%Y-%m-%d") if self.due_date else "No due
date"
18. return f"{self.title} - {'Completed' if self.completed else 'Pending'} (Due:
{due_date_str}, Priority: {self.priority})"
19.
20. class Project:
21. def __init__(self, name):
22. self.name = name
23. self.tasks = []
24.
25. def add_task(self, task):
26. self.tasks.append(task)
27.
28. def complete_task(self, task_title):
29. for task in self.tasks:
30. if task.title == task_title:
31. task.mark_completed()
32. break
33.
34. def show_tasks(self):
35. return [str(task) for task in self.tasks]
36.
37. class TaskManagerApp:
38. def __init__(self, root):
39. self.root = root
40. self.root.title("Task Manager")
41. self.project = Project("My Project")
42.
43. self.task_listbox = tk.Listbox(root, width=50)
44. self.task_listbox.pack(pady=10)
45.
46. self.add_task_button = tk.Button(root, text="Add Task", command=self.add_task)
47. self.add_task_button.pack(pady=5)
48.
49. self.complete_task_button = tk.Button(root, text="Complete Task",
command=self.complete_task)
50. self.complete_task_button.pack(pady=5)
51.
52. self.show_tasks_button = tk.Button(root, text="Show Tasks",
command=self.show_tasks)
53. self.show_tasks_button.pack(pady=5)
54.
55. def add_task(self):
56. title = simpledialog.askstring("Task Title", "Enter task title:")
57. description = simpledialog.askstring("Task Description", "Enter task description:")
58. due_date_input = simpledialog.askstring("Due Date", "Enter due date (YYYY-MM-
DD) or leave blank:")
59. due_date = datetime.strptime(due_date_input, "%Y-%m-%d") if due_date_input
else None
60. priority = simpledialog.askstring("Priority", "Enter task priority (Low, Normal,
High):")
61. task = Task(title, description, due_date, priority)
62. self.project.add_task(task)
63. self.show_tasks()
64.
65. def complete_task(self):
66. selected_task = self.task_listbox.curselection()
67. if selected_task:
68. task_title = self.task_listbox.get(selected_task).split(" - ")[0]
69. self.project.complete_task(task_title)
70. self.show_tasks()
71. else:
72. messagebox.showwarning("Warning", "Please select a task to complete.")
73.
74. def show_tasks(self):
75. self.task_listbox.delete(0, tk.END)
76. for task in self.project.show_tasks():
77. self.task_listbox.insert(tk.END, task)
78.
79. if __name__ == "__main__":
80. root = tk.Tk()
81. app = TaskManagerApp(root)
82. root.mainloop()
This code creates a simple GUI application for managing tasks. The user can add tasks, mark
them as completed, and view the list of tasks. The TaskManagerApp class handles the GUI
components and user interactions. You can further enhance this application by adding
features such as saving and loading tasks from a file, filtering tasks, and improving the layout
and design of the GUI.
Consider adding error handling for user inputs and enhancing the user experience with
additional features like sorting tasks or displaying task details in a separate window. This will
make the application more robust and user-friendly. You can also implement a feature to edit
existing tasks, allowing users to modify the title, description, due date, or priority of a task.
Here’s how you can add an edit functionality to the GUI application:
Editing Tasks: Add a method in the TaskManagerApp class to handle task editing.
1. def edit_task(self):
2. selected_task = self.task_listbox.curselection()
3. if selected_task:
4. task_title = self.task_listbox.get(selected_task).split(" - ")[0]
5. for task in self.project.tasks:
6. if task.title == task_title:
7. new_title = simpledialog.askstring("Edit Task Title", "Enter new task title:",
initialvalue=task.title)
8. new_description = simpledialog.askstring("Edit Task Description", "Enter new
task description:", initialvalue=task.description)
9. new_due_date_input = simpledialog.askstring("Edit Due Date", "Enter new
due date (YYYY-MM-DD) or leave blank:", initialvalue=task.due_date.strftime("%Y-
%m-%d") if task.due_date else "")
10. new_due_date = datetime.strptime(new_due_date_input, "%Y-%m-%d") if
new_due_date_input else None
11. new_priority = simpledialog.askstring("Edit Priority", "Enter new task priority
(Low, Normal, High):", initialvalue=task.priority)
12.
13. task.title = new_title
14. task.description = new_description
15. task.due_date = new_due_date
16. task.priority = new_priority
17. break
18. self.show_tasks()
19. else:
20. messagebox.showwarning("Warning", "Please select a task to edit.")
Updating the GUI: Add a button for editing tasks in the `__init__` method of the
TaskManagerApp class.
1. self.edit_task_button = tk.Button(root, text="Edit Task", command=self.edit_task)
2. self.edit_task_button.pack(pady=5)
Complete Updated GUI Code: Here’s the complete updated code with the edit
functionality included.
1. import tkinter as tk
2. from tkinter import messagebox, simpledialog
3. from datetime import datetime
4.
5. class Task:
6. def __init__(self, title, description, due_date=None, priority='Normal'):
7. self.title = title
8. self.description = description
9. self.completed = False
10. self.due_date = due_date
11. self.priority = priority
12.
13. def mark_completed(self):
14. self.completed = True
15.
16. def __str__(self):
17. due_date_str = self.due_date.strftime("%Y-%m-%d") if self.due_date else "No due
date"
18. return f"{self.title} - {'Completed' if self.completed else 'Pending'} (Due:
{due_date_str}, Priority: {self.priority})"
19.
20. class Project:
21. def __init__(self, name):
22. self.name = name
23. self.tasks = []
24.
25. def add_task(self, task):
26. self.tasks.append(task)
27.
28. def complete_task(self, task_title):
29. for task in self.tasks:
30. if task.title == task_title:
31. task.mark_completed()
32. break
33.
34. def show_tasks(self):
35. return [str(task) for task in self.tasks]
36.
37. class TaskManagerApp:
38. def __init__(self, root):
39. self.root = root
40. self.root.title("Task Manager")
41. self.project = Project("My Project")
42.
43. self.task_listbox = tk.Listbox(root, width=50)
44. self.task_listbox.pack(pady=10)
45.
46. self.add_task_button = tk.Button(root, text="Add Task", command=self.add_task)
47. self.add_task_button.pack(pady=5)
48.
49. self.complete_task_button = tk.Button(root, text="Complete Task",
command=self.complete_task)
50. self.complete_task_button.pack(pady=5)
51.
52. self.edit_task_button = tk.Button(root, text="Edit Task", command=self.edit_task)
53. self.edit_task_button.pack(pady=5)
54.
55. self.show_tasks_button = tk.Button(root, text="Show Tasks",
command=self.show_tasks)
56. self.show_tasks_button.pack(pady=5)
57.
58. def add_task(self):
59. title = simpledialog.askstring("Task Title", "Enter task title:")
60. description = simpledialog.askstring("Task Description", "Enter task description:")
61. due_date_input = simpledialog.askstring("Due Date", "Enter due date (YYYY-MM-
DD) or leave blank:")
62. due_date = datetime.strptime(due_date_input, "%Y-%m-%d") if due_date_input
else None
63. priority = simpledialog.askstring("Priority", "Enter task priority (Low, Normal,
High):")
64. task = Task(title, description, due_date, priority)
65. self.project.add_task(task)
66. self.show_tasks()
67.
68. def complete_task(self):
69. selected_task = self.task_listbox.curselection()
70. if selected_task:
71. task_title = self.task_listbox.get(selected_task).split(" - ")[0]
72. self.project.complete_task(task_title)
73. self.show_tasks()
74. else:
75. messagebox.showwarning("Warning", "Please select a task to complete.")
76.
77. def edit_task(self):
78. selected_task = self.task_listbox.curselection()
79. if selected_task:
80. task_title = self.task_listbox.get(selected_task).split(" - ")[0]
81. for task in self.project.tasks:
82. if task.title == task_title:
83. new_title = simpledialog.askstring("Edit Task Title", "Enter new task title:",
initialvalue=task.title)
84. new_description = simpledialog.askstring("Edit Task Description", "Enter
new task description:", initialvalue=task.description)
85. new_due_date_input = simpledialog.askstring("Edit Due Date", "Enter new
due date (YYYY-MM-DD) or leave blank:", initialvalue=task.due_date.strftime("%Y-
%m-%d") if task.due_date else "")
86. new_due_date = datetime.strptime(new_due_date_input, "%Y-%m-%d") if
new_due_date_input else None
87. new_priority = simpledialog.askstring("Edit Priority", "Enter new task
priority (Low, Normal, High):", initialvalue=task.priority)
88.
89. task.title = new_title
90. task.description = new_description
91. task.due_date = new_due_date
92. task.priority = new_priority
93. break
94. self.show_tasks()
95. else:
96. messagebox.showwarning("Warning", "Please select a task to edit.")
97.
98. def show_tasks(self):
99. self.task_listbox.delete(0, tk.END)
100. for task in self.project.show_tasks():
101. self.task_listbox.insert(tk.END, task)
102.
103. if __name__ == "__main__":
104. root = tk.Tk()
105. app = TaskManagerApp(root)
106. root.mainloop()
This updated code now includes the ability to edit existing tasks, enhancing the functionality
of the task management tool. Users can modify task details, making it easier to keep their
task list up to date. You can continue to expand this application by adding more features,
such as sorting tasks, filtering by due date or priority, and improving the overall user
interface. You can also consider implementing a feature to categorize tasks into different
projects or tags, allowing users to organize their tasks more effectively. This could involve
creating a Category class and associating tasks with specific categories. Here’s a basic
implementation of how you might add categories to your task management tool:
Updating User Interaction: Modify the command-line interface to include options for
adding categories and assigning tasks to categories.
1. def main():
2. project_name = input("Enter the project name: ")
3. project = Project(project_name)
4.
5. while True:
6. print("\nOptions:")
7. print("1. Add Category")
8. print("2. Add Task to Category")
9. print("3. Show Tasks by Category")
10. print("4. Exit")
11.
12. choice = input("Choose an option: ")
13.
14. if choice == '1':
15. category_name = input("Enter category name: ")
16. project.add_category(category_name)
17. print("Category added.")
18.
19. elif choice == '2':
20. category_name = input("Enter category name to add task to: ")
21. title = input("Enter task title: ")
22. description = input("Enter task description: ")
23. task = Task(title, description)
24. project.add_task_to_category(category_name, task)
25. print("Task added to category.")
26.
27. elif choice == '3':
28. category_name = input("Enter category name to show tasks: ")
29. tasks = project.show_tasks_by_category(category_name)
30. print(f"\nTasks in category '{category_name}':")
31. for task in tasks:
32. print(task)
33.
34. elif choice == '4':
35. print("Exiting...")
36. break
37.
38. else:
39. print("Invalid option. Please try again.")
This implementation allows users to create categories and assign tasks to those categories,
providing a more organized way to manage tasks. You can further enhance this feature by
allowing users to view all categories, delete categories, or move tasks between categories.
Additionally, consider implementing a search functionality that allows users to find tasks
based on keywords in the title or description. This would make it easier for users to locate
specific tasks within larger projects. Here’s a simple implementation of a search feature:
Search Functionality: Add a method in the Project class to search for tasks.
1. class Project:
2. # Existing methods...
3.
4. def search_tasks(self, keyword):
5. found_tasks = []
6. for category in self.categories.values():
7. for task in category.tasks:
8. if keyword.lower() in task.title.lower() or keyword.lower() in
task.description.lower():
9. found_tasks.append(task)
10. return found_tasks
Updating User Interaction: Modify the command-line interface to include an option
for searching tasks.
1. def main():
2. project_name = input("Enter the project name: ")
3. project = Project(project_name)
4.
5. while True:
6. print("\nOptions:")
7. print("1. Add Category")
8. print("2. Add Task to Category")
9. print("3. Show Tasks by Category")
10. print("4. Search Tasks")
11. print("5. Exit")
12.
13. choice = input("Choose an option: ")
14.
15. if choice == '1':
16. category_name = input("Enter category name: ")
17. project.add_category(category_name)
18. print("Category added.")
19.
20. elif choice == '2':
21. category_name = input("Enter category name to add task to: ")
22. title = input("Enter task title: ")
23. description = input("Enter task description: ")
24. task = Task(title, description)
25. project.add_task_to_category(category_name, task)
26. print("Task added to category.")
27.
28. elif choice == '3':
29. category_name = input("Enter category name to show tasks: ")
30. tasks = project.show_tasks_by_category(category_name)
31. print(f"\nTasks in category '{category _name}':")
32. for task in tasks:
33. print(task)
34.
35. elif choice == '4':
36. keyword = input("Enter keyword to search for tasks: ")
37. found_tasks = project.search_tasks(keyword)
38. print(f"\nTasks matching '{keyword}':")
39. for task in found_tasks:
40. print(task)
41.
42. elif choice == '5':
43. print("Exiting...")
44. break
45.
46. else:
47. print("Invalid option. Please try again.")
This addition allows users to search for tasks based on keywords, making it easier to find
specific tasks within their project. You can continue to enhance the application by adding
more features, such as notifications for upcoming due dates, integration with calendars, or
even a web-based interface for easier access. You can also consider implementing user
authentication to allow multiple users to manage their tasks securely. This could involve
creating a user management system where users can register, log in, and have their own
separate task lists. Here’s a basic outline of how you might implement user authentication:
Updating the Main Functionality: Modify the main function to include user
registration and login.
1. def main():
2. while True:
3. print("\nOptions:")
4. print("1. Register")
5. print("2. Login")
6. print("3. Exit")
7.
8. choice = input("Choose an option: ")
9.
10. if choice == '1':
11. register_user()
12.
13. elif choice == '2':
14. user = login_user()
15. if user:
16. while True:
17. print("\nProject Options:")
18. print("1. Add Project")
19. print("2. Select Project")
20. print("3. Logout")
21.
22. project_choice = input("Choose an option: ")
23.
24. if project_choice == '1':
25. project_name = input("Enter project name: ")
26. user.add_project(project_name)
27. print("Project added.")
28.
29. elif project_choice == '2':
30. project_name = input("Enter project name to select: ")
31. project = user.get_project(project_name)
32. if project:
33. # Continue with task management for the selected project
34. manage_tasks(project)
35. else:
36. print("Project not found.")
37.
38. elif project_choice == '3':
39. print("Logging out...")
40. break
41.
42. else:
43. print("Invalid option. Please try again.")
44.
45. elif choice == '3':
46. print("Exiting...")
47. break
48.
49. else:
50. print("Invalid option. Please try again.")
51.
52. def manage_tasks(project):
53. while True:
54. print("\nTask Options:")
55. print("1. Add Task")
56. print("2. Show Tasks")
57. print("3. Exit")
58.
59. task_choice = input("Choose an option: ")
60.
61. if task_choice == '1':
62. title = input("Enter task title: ")
63. description = input("Enter task description: ")
64. task = Task(title, description)
65. project.add_task(task)
66. print("Task added.")
67.
68. elif task_choice == '2':
69. print(f"\nTasks for project '{project.name}':")
70. for task in project.show_tasks():
71. print(task)
72.
73. elif task_choice == '3':
74. print("Exiting task management...")
75. break
76.
77. else:
78. print("Invalid option. Please try again.")
This implementation allows users to register and log in, managing their own projects and
tasks securely. You can further enhance this feature by adding password hashing for security,
allowing users to reset their passwords, and implementing a database for persistent storage
of user data.
Consider also adding a feature to allow users to share projects with others, enabling
collaboration on tasks. This could involve creating a system for inviting users to projects and
managing permissions for viewing or editing tasks.
By continuously expanding the functionality of your task management tool, you can create a
comprehensive application that meets a wide range of user needs, making it a valuable
resource for personal and team productivity. You can also consider implementing a feature to
generate reports on task completion rates, overdue tasks, and overall project progress. This
could involve creating a method in the Project class to analyze tasks and provide insights.
Here’s a basic implementation of how you might generate a report:
Additionally, consider implementing reminders for tasks based on their due dates. This could
involve integrating with a notification system or sending email reminders to users. You can
use libraries like smtplib for sending emails or explore task scheduling libraries like schedule
to manage reminders within the application. By continuously adding features and improving
the user experience, you can create a powerful task and project management tool that caters
to a wide range of user needs, enhancing productivity and collaboration. You can also
consider implementing a feature to allow users to set recurring tasks, which would be
particularly useful for tasks that need to be completed on a regular basis. This could involve
adding a recurrence attribute to the Task class and modifying the task management logic to
handle these recurring tasks appropriately. Here’s how you might implement this feature:
Updating the Task Class: Add a recurrence attribute to the Task class.
1. class Task:
2. def __init__(self, title, description, due_date=None, priority='Normal',
recurrence=None):
3. self.title = title
4. self.description = description
5. self.completed = False
6. self.due_date = due_date
7. self.priority = priority
8. self.recurrence = recurrence # e.g., 'daily', 'weekly', 'monthly'
9.
10. def mark_completed(self):
11. self.completed = True
12.
13. def __str__(self):
14. due_date_str = self.due_date.strftime("%Y-%m-%d") if self.due_date else "No due
date"
15. return f"{self.title} - {'Completed' if self.completed else 'Pending'} (Due:
{due_date_str}, Priority: {self.priority}, Recurrence: {self.recurrence})"
Handling Recurring Tasks: Modify the logic for displaying tasks to account for recurring
tasks. You may want to create new instances of the task based on the recurrence
pattern when displaying tasks.
1. def show_tasks(self):
2. self.task_listbox.delete(0, tk.END)
3. for task in self.project.show_tasks():
4. if task.recurrence:
5. # Logic to generate future instances of recurring tasks
6. # For example, if the task is daily, create a new instance for each day until a
certain date
7. # This is a simplified example; you may want to implement more robust logic
8. future_due_date = task.due_date
9. while future_due_date < datetime.now() + timedelta(days=30): # Show tasks
for the next 30 days
10. future_task = Task(task.title, task.description, future_due_date, task.priority,
task.recurrence)
11. self.task_listbox.insert(tk.END, str(future_task))
12. if task.recurrence == 'daily':
13. future_due_date += timedelta(days=1)
14. elif task.recurrence == 'weekly':
15. future_due_date += timedelta(weeks=1)
16. elif task.recurrence == 'monthly':
17. future_due_date += timedelta(days=30) # Simplified for demonstration
18. else:
19. self.task_listbox.insert(tk.END, str(task))
This implementation allows users to set recurring tasks, making it easier to manage regular
responsibilities. You can further enhance this feature by allowing users to specify an end date
for the recurrence or to skip certain occurrences.
Additionally, consider implementing a dashboard view that provides an overview of tasks,
including statistics such as the number of completed tasks, overdue tasks, and upcoming
tasks. This could involve creating a separate GUI window or section that displays these
statistics visually, perhaps using charts or graphs.
By continuously enhancing the functionality and user experience of your task management
tool, you can create a comprehensive application that meets a wide range of user needs,
ultimately improving productivity and collaboration. You can also consider integrating third-
party APIs for additional features, such as syncing tasks with calendar applications (like
Google Calendar) or project management tools (like Trello or Asana). This would allow users
to manage their tasks across different platforms seamlessly.
Integrating with Google Calendar: You can use the Google Calendar API to create
events based on tasks. Users would need to authenticate their Google account, and
you can use libraries like google-auth and google-api-python-client to handle the
integration.
Example of Adding a Task to Google Calendar:
1. from google.oauth2.credentials import Credentials
2. from googleapiclient.discovery import build
3.
4. def add_task_to_google_calendar(task):
5. creds = Credentials.from_authorized_user_file('token.json', SCOPES)
6. service = build('calendar', 'v3', credentials=creds)
7.
8. event = {
9. 'summary': task.title,
10. 'description': task.description,
11. 'start': {
12. 'dateTime': task.due_date.isoformat(),
13. 'timeZone': 'America/Los_Angeles', # Adjust as necessary
14. },
15. 'end': {
16. 'dateTime': (task.due_date + timedelta(hours=1)).isoformat(), # Assuming 1-
hour duration
17. 'timeZone': 'America/Los_Angeles',
18. },
19. }
20.
21. event = service.events().insert(calendarId='primary', body=event).execute()
22. print(f"Task '{task.title}' added to Google Calendar: {event.get('htmlLink')}")
User Authentication for Google API: You would need to set up OAuth 2.0 credentials in
the Google Developer Console and handle the authentication flow in your application.
Dashboard View: For a dashboard, you can use libraries like matplotlib or seaborn to
create visual representations of task statistics. This could include pie charts for task
completion rates or bar graphs for overdue tasks.
Example of Creating a Simple Dashboard:
1. import matplotlib.pyplot as plt
2.
3. def create_dashboard(project):
4. completed = sum(1 for task in project.tasks if task.completed)
5. total = len(project.tasks)
6. overdue = sum(1 for task in project.tasks if task.due_date and task.due_date <
datetime.now() and not task.completed)
7.
8. labels = ['Completed', 'Pending', 'Overdue']
9. sizes = [completed, total - completed, overdue]
10. colors = ['#4CAF50', '#FFC107', '#F44336']
11.
12. plt.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=90)
13. plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
14. plt.title(f"Task Overview for {project.name}")
15. plt.show()
User Interface Enhancements: Consider improving the user interface with a more modern
look using libraries like tkinter.ttk for themed widgets or even transitioning to a web-based
interface using frameworks like Flask or Django. This would allow for a more responsive
design and easier access from various devices.
By continuously iterating on your application and incorporating user feedback, you can create
a robust task and project management tool that not only meets the needs of individual users
but also supports team collaboration and productivity.