As a practicing musician for over eight years, I find it valuable to write down what I practice. It helps me focus on what needs to be improved and it also provides a record of my progress. I fill notebook after notebook with my practice sessions and decided it was time to use a program to keep track of my progress.
After testing out multiple desktop and mobile applications, I couldn’t find a program I liked. It was at this point that I decided to code the program myself. By doing so, I could develop the application with the features I wanted and further my programming skills. After six hours of development, PracticeJournal was born!
PracticeJournal is a desktop application for the practicing musician. The app has a simple user interface (shown on right) and logs each submission to a database file. A user can easily check their entries by pressing the “Open” button (opens a HTML table of the data).
The app has two fields and a spinbox for the user to complete (respectively): what you practiced, additional notes, and practice rating. A user types their practice information in the two fields and provides a rating of how the practice went out of ten in the spinbox. After the above is done, the user presses the “Submit” button.
After the submission, the user can press the “Open” button to see all their entries. Note that a browser will open and will display all your entries with their entry number and date of submission (see below).
In order for the app to display the entries in the HTML file, the entries must be saved somewhere. In this case, the app saves each entry into an SQL database file named journal.db. Once the entry is saved into journal.db, the app calls the below function:
def write_html(html_file, html_format, entries): try: file = open(html_file, "w") except IOError: raise key = int(entries[0]) + 1 # Accounts for zero-based numbering date = entries[1] practiced = entries[2] notes = entries[3] rating = entries[4] # entry_str is formatted HTML in a string literal entry_str = entry_str.format(key=key, date=date, practiced=practiced, notes=notes, rating=rating) html_format.insert(-3, entry_str) # Inserts a table row in html table for line in html_format: file.writelines(line) file.close()
This function seems complicated, but I will walk you through what it does step by step.
The first block of code (below) tries to open the HTML file (html_file) in write mode. Note that when a file is opened in write mode, the contents of the file are wiped! This function needs the files contents before it can be written to (see html_format). So, the app calls another function before write_html that opens and returns the file’s contents (not shown).
try: file = open(html_file, "w") except IOError: raise
Next, write_html sorts the data from the variable entries into five other variables. These five variables are entered into a formatted HTML string literal (not shown) which is then inserted as a row into a HTML table (represented as a list of lines):
key = int(entries[0]) + 1 # Accounts for zero-based numbering date = entries[1] practiced = entries[2] notes = entries[3] rating = entries[4] # entry_str is formatted HTML in a string literal entry_str = entry_str.format(key=key, date=date, practiced=practiced, notes=notes, rating=rating) html_format.insert(-3, entry_str) # Inserts a table row in html table
Finally, the function takes each line in the list, writes it to html_file, and closes it:
for line in html_format: file.writelines(line) file.close()
I have been meaning to do this project for quite some time. Every time I completed a practice session, I always thought about building this app. Now that it is complete, I can start using it!
The project will most likely go through multiple versions as I tailor it to my needs. If you are a musician in need of such an app, feel free to download it (just follow the installation instructions found in the PracticeJournal README.md file).
Overall, I really enjoyed building this app and I hope that it benefits the practicing musician.
If you are a musician, would you use this type of app? What kind of features would you like in this app? Leave your comments below and tell me what you think!