How to keep track of your ToDo’s | Journal #6
Isn’t it just hard to keep track of your ToDo’s? Well I have the BEST solution for you!
Do you ever find it hard to do you chores? I do. Because I'm lazy… Well anyway that doesn’t matter, right? So, because I’m lazy I need to kind of automate this task.
Obviously you can’t automate keeping track of ToDo’s but you can make something to help you keep track of it. So lets plan this program which will help us in the long run.
Phase 1 | Planning
So lets put it simply. If I didn’t have a program to help what would I do in real life. Firstly, I would firstly add a task. So lets note that down. Next we need to have a remove task feature. Again, lets note this down. We want a function which displays / refreshes the tasks. Lets note this down. We need to have a quit function so that you can stop the code. Note this down. Lastly, we need a auto-save into a .txt file. Now lets note it down.
- We need to make a function which lets you add a task.
- We need to make a function which lets you remove one of your added tasks
- We need to make a function which lets you display the tasks.
- We need to Quit the ToDo’s manager
- We need it to save the ToDo’s
Done! Planning Phase finished.
Phase 2 | Scripting
So, to make this To Do list program we need to code it in Python with Tk (Tkinter). I won’t be explaining the Quit to do manager as that is literally just one line of code and also I won’t have a section about saving the ToDo's because its just in the .txt file.
IMPORTS
Imports are pretty simple and it is only one import and that is Tkinter imported as Tk.
Display Tasks Function
We start off with opening Todo.txt as a reader. We make a variable called tasks equalling the lines that the computer read from your file being ToDo.txt. The rest is quite confusing but really what the function does is read every separate line (every task takes up one line) and just show you that, and if there aren’t any tasks then it shows “No tasks in your list.”
Add Task Function
We get the task variable which is whatever we put in the task add text box then open Todo.txt for appending. To append the file we need to get the task variable which we just got. Then we write the task variable and add a \n which means next line. Then this is kind of important, we run the display task function in the add task function so its a live update.
Remove Task Function
So to start off we need to make a variable for the selected task. Meaning we need to get a way to select a task. So how do we do this? We make a box for the tasks then we make it so we have a cursor selection tool and whichever task we select will become our selected task. Then we make a task index and task number. We make the task index the selected task and the task number become the task number + 1. Then we open Todo.txt as an reader and make the task variable equal the lines your computer read from ToDo.txt. Then we open Todo.txt as a writer (“w” not “a”). Again there is some confusing stuff that I wont explain but you can look at in the GitHub code below.
PHASE 3 | RELEASE
Ahh yes! It is now officially finished! The GitHub Repo will be in the Links section below. But now it is time for me to thank you, seriously. If you have gotten this far I would be really impressed. Remember this is all an open source project you can always steal my code to make it better. I hope I explained everything well to you, if I didn’t feel free to leave a reply and tell me what I do wrong. So now its time to say farewell! I hope i see you again. The links section will be below.
LINKS
Subscribe to JDJ Newsletter: Subscribe! Journal #6
GitHub Repo: GitHub Repo | Journal #6