The Love Chronicles of a 20-Year-Old: How I Keep Track of My Valentine's Dates

The Love Chronicles of a 20-Year-Old: How I Keep Track of My Valentine's Dates

The full code can be found at https://github.com/Armigerous/valentines_data

Ah, Valentine's Day. The day of love, flowers, chocolates, and for some, awkward first dates. For me, it's a day to celebrate the ups and downs of love and the memories that come with it. But how do I keep track of all those memories? Well, my dear reader, I have a secret weapon: a python program.

Yes, you heard that right! I created a python program to keep track of my Valentine's dates. It's like a digital diary, where I can store all the important details of my Valentine's Day experiences. I know, I know. Some of you may think it's nerdy, but trust me, it's a lifesaver. I never have to worry about forgetting the name of that girl I went on a date with in 2018, or the year I had my first kiss. My program has got me covered.

But let's backtrack a little bit. Before we dive into my program, let me give you a quick overview of what it does. It's a program that asks if you have a date for Valentine's Day, and if the answer is yes, it takes in the date, the name of your date, and the year. If the answer is no, well, it doesn't do anything. But if you choose the "Previous Years" option, it shows you all the data you've entered in the past.

Now that you have an idea of what the program does, let's take a look at the code. The first few lines import the necessary libraries, such as os, tkinter, and PIL. The program sets the background color and sets today's date using the datetime library.

import os
import tkinter as tk
import customtkinter as ctk
from PIL import ImageTk
import sqlite3
from datetime import date

The next part is where the program creates a database using SQLite. It changes the current directory to where the database is stored and creates a connection to the database.

#change dir to the database's location
os.chdir(r"C:\Users\tugra\OneDrive\Desktop\fun\valentines_data\data")
#create database
connection = sqlite3.connect("valentine_tracker.db")
cursor = connection.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS dates (year integer, date text, name)")

After that, the program has three functions to pre-process the data. The first function, fetch_db(), fetches the data from the database. The second function, pre_process(), processes the data by adding the year, the date, and the name to a list. The final function, load_menu(), displays the menu, where you can choose whether you have a date for Valentine's Day or to view the previous years' data.

#get data from db
def fetch_db():
    cursor.execute("SELECT * FROM dates")
    table_records = cursor.fetchall()
    return table_records

#clean the data from db
def pre_process():
    table_records = fetch_db()
    
    dates = []
    for i in table_records:
        year = i[0]
        valentine = i[1]
        name = i[2]

        if name != "":
            dates.append(str(year) + " == " + valentine + " == " + name)
        else:
            dates.append(str(year) + " == " + valentine)

    
    return dates

#menu
def load_menu():
    clear_widgets(data_view)
    menu.tkraise()
    #stops from children from changing  menu
    menu.pack_propagate(False)

    logo_img = ImageTk.PhotoImage(file=r"C:\Users\tugra\OneDrive\Desktop\fun\valentines_data\assets\white_heart.png")
    logo_widget = tk.Label(menu, image=logo_img, bg=bg_color)
    logo_widget.image = logo_img
    logo_widget.pack()

    #the question
    tk.Label(
        menu,
        text="Do you have a date for Valentine's Day this year?",
        bg=bg_color,
        fg="white",
        font=("Comic Sans", 14),
        ).pack(side="top")
    
    
    button = ctk.CTkButton(
        master=menu,
        width=250,
        height=60,
        border_width=0,
        corner_radius=7,
        fg_color=burgundy,
        hover_color=pastel_red,
        border_color="black",
        text="Yes",
        font=('Comic Sans', 30),
        command=lambda:load_frame_yes()
        )
    button.pack(pady=10)

    button = ctk.CTkButton(
        master=menu,
        width=250,
        height=60,
        border_width=0,
        corner_radius=7,
        fg_color=burgundy,
        hover_color=pastel_red,
        border_color="black",
        text="No",
        font=('Comic Sans', 30),
        command=lambda:button_no()
        )
    button.pack(pady=10)

    button = ctk.CTkButton(
        master=menu,
        width=250,
        height=60,
        border_width=0,
        corner_radius=7,
        fg_color=burgundy,
        hover_color=pastel_red,
        border_color="black",
        text="Previous Years",
        font=('Comic Sans', 30),
        command=lambda:load_data_view()
        )
    button.pack(pady=10)

The next function is the "load_data_view()" function. This function is called when the "Previous Years" button on the menu is clicked.

The "load_data_view()" function first clears any existing widgets in the "menu" frame, and raises the "data_view" frame so that it becomes the current visible frame.

After that, it adds a white heart logo to the "data_view" frame. It also adds a title "Dating Records for Valentine's Day in the Past Years" to the frame.

Next, it calls the "pre_process()" function to obtain the dates of all the previous Valentine's Day dates that are recorded in the database. The pre-processed dates are then displayed as individual labels in the "data_view" frame. Each label has a background color of burgundy and text color of white.

The last function in this code is the "clear_widgets()" function. This function takes in a frame as an argument, and removes all widgets from the frame. This function is used in "load_menu()" and "load_data_view()" to clear the existing widgets in the frames before adding new widgets.

In conclusion, this code is for a program that helps you track your Valentine's Day dates. You can choose to add or view previous Valentine's Day dates. The program makes use of SQLite database to store the dates, Tkinter for the GUI, and the customtkinter library for creating custom buttons.

And that's the end of my discussion on this code!

The way I use the code is with Task Scheduler. I turned the .py to an executable file, .exe.

I have the trigger set up every year for valentine's day, the app pops up and asks me if I have a date for the day every year.

Thanks for tuning in, I hope you enjoyed reading my comments on the code. Happy Valentine's Day!!!!