This project uses python’s tkinter library for the user interface. The user is asked if they followed through on their habit. If yes, the led lights up and a connection with Evernote is triggered, which appends the current time to the To-Do note. If no, then the buzzer beeps long enough to boo them for not following through ;)
1. Evernote
Evernote is an app designed for note taking, organizing, task management, and archiving.
We’re using it because we want to log all the times we remembered to do our habit.
To do this
1. Sign up on Evernote
2. Go to My notebook and create a new note with a title like Habit logging
That’s it about Evernote. Now lets see how Integromat will help us.
2. INTEGROMAT - the glue of the internet
Remember we wanted the YES in the tkinter app to trigger something in Evernote? How will we connect a python code, a bolt module, and Evernote?
As their punchline says, integromat is like glue you can use to stick applications together.
To configure this according to our needs:
1. First create an integromat account.
2. Click on create a new scenario on the top right corner
3. Select webhooks and Evernotes as the modules
4. Select Custom webhook and copy the generated url, we will use it later.
5. Add the other module as Evernote. Under Actions select Append content to a note.
6. Under select a note, click on select. Then select My notebooks, and select the title you just gave your habit note. Then under contents, go to the date and time section select the variable “now”
7. Tell it to run the scenario everyday
8. Finally, your page will look like this
Now about the code
3. Writing the Python Code:
3.1 Connecting Bolt and python
We start by importing the Bolt Module.
We then write a function for the YES (light up the led) and a function for the NO (buzzer, led off)
Now we also want to trigger the webhook when the user says YES, so that we can enter it in their Evernote.
3.2 The webhook:
The code for making the webhook listen is:
Make sure to use the url you’ve copied from before.
3.3 Now putting together these two codes:
Notice that we’re calling the trigger function in the ledON() function.
3.4 Tkinter
Using Python’s tkinter library we now want to make a user interface.
The height and width are the dimensions of the pop up.
The root is where the things happen in tkinter. You can notice that we’re passing the root variable into the frame.
The frame is where we’re placing different buttons and labels. And the frames and buttons and labels have various attributes, like relative height (relheight), relative x coordinate(relx), color, font, etc.
We can play around with these values till we get the look we want. (The tkinter documentation https://tkdocs.com/tutorial/index.html )
Now, as we want these buttons to do something when pushed. So we specify what we what them to do in the command attribute.
(Lambda functions in Python are used to create anonymous functions and are very useful)
So in the command attribute, we call the ledON and ledOFF functions we’ve already defined.
1.5 I've attached the complete code in the end!
Video:
Comments