The Python terminal Habit Tracker is a command-line application designed to help you keep track of your daily habits and monitor your progress. It consists of five Python files: "recurrence.py," "habit.py," "habitTracker.py," "habitTrackerApp.py," and "main.py." Each of these files serves a specific purpose within the application.
This file contains the definition of recurrence types and a class for handling recurrence.
-
RecurrenceType
: An enumeration representing different recurrence types, including DAILY, WEEKLY, MONTHLY, and YEARLY. -
Recurrence
: A class that defines a recurrence with a specific type and interval. It provides methods to calculate the next occurrence based on the last one.
In this file, you'll find classes related to habits and their history.
-
HabitCompletionHistoryPoint
: A class representing a completion point for a habit on a specific date. -
Habit
: A class that defines a habit with a name, description, first deadline, recurrence, and completion history. It includes methods for completing a habit, calculating the longest streak, and displaying habit information.
This file contains the HabitTracker
class responsible for managing a list of habits. It also provides methods to add, list, and manipulate habits.
This file defines the HabitTrackerApp
class, which is a command-line application for interacting with the habit tracker. It includes methods for creating, listing, and managing habits, as well as saving and loading habits from a file.
To use the Habit Tracker, you can run the main.py
script. This script creates an instance of the HabitTrackerApp
class with some predefined habits. You can customize these habits or add your own by following the prompts in the command-line interface.
-
Run the
main.py
script to start the Habit Tracker application. -
Choose from various options in the menu, such as creating habits, listing habits, listing habits by recurrence, and more.
-
Follow the prompts to input habit details and manage your habits.
-
You can also save and load your habits from a file for persistence.
The main.py
script provides some example predefined habits, including "Daily Exercise," "Weekly Reading," "Meditation," "Healthy Eating," and "Language Learning." These habits have different recurrences and completion histories, which can serve as a reference for creating your own habits.
-
Make sure you have Python installed on your system.
-
The application stores habits in a pickle file by default ("tasks.pickle"). You can choose a custom file path when saving or loading habits.
-
Be cautious when modifying the code, especially if you're new to Python programming. Incorrect changes may break the functionality.
-
The application is designed for educational purposes and personal use. Feel free to adapt and expand it to meet your specific needs.
This Habit Tracker application was created as a sample Python project and provided with code examples by Volodymyr Bezpalko.
This is not a production-ready application. Use it at your own discretion and feel free to improve it or customize it to better suit your requirements.
Enjoy tracking and building healthy habits with the Habit Tracker!