# Judith's stupid shitty fucking savings tracker # The supporting code import tkinter as tk # imports tkinter from tkinter import ttk # imports ttk root = tk.Tk() # sets up tkinter window root.title("Savings Calculator") # adds window title root.geometry("600x400") # sets window geometry root.resizable(False, False) # don't want those pesky users fucking up the beuatiful ui :3 # The pretty™ topLabel = ttk.Label(text="The savings calculator\n Calculate your savings today!", justify="center") # The top label. topLabel.grid(column=1, row=0, columnspan=3, padx=10, pady=10) # if anyone complains this is the only fucking way I could make it work # The length label lengthLabel = ttk.Label(text="Over: ") lengthLabel.grid(column=1, row=1, pady=10, padx=10, sticky="w") # The length input lengthInput = ttk.Entry() lengthInput.grid(column=2, row=1, pady=10, padx=5, sticky="ew") # The length combobox [DEPRECATED and i'm too lazy to remove the code hehehe] """ lengthVar = tk.StringVar(value='Weeks') lengthCBox = ttk.Combobox(root, textvariable=lengthVar, state='readonly') lengthCBox['values'] = ('Weeks', 'Months', 'Years') lengthCBox.current(0) lengthCBox.grid(column=3, row=1, pady=10, padx=10, sticky="ew") """ # The other length label lengthLabelStringVar = tk.StringVar() lengthLabelStringVar.set("Months") lengthLabelTheSecond = ttk.Label(textvariable=lengthLabelStringVar) lengthLabelTheSecond.grid(column=3, row=1, pady=10, padx=10, sticky="ew") # all codey no worky make judy go crazy # The deposit label depositLabel = ttk.Label(text="I will deposit: $") depositLabel.grid(column=1, row=2, pady=10, padx=10, sticky="w") # The deposit input depositInput = ttk.Entry() depositInput.grid(column=2, row=2, pady=10, padx=5, sticky="ew") # The deposit combobox depositVar = tk.StringVar(value='Monthly') depositCBox = ttk.Combobox(root, textvariable=depositVar, state='readonly') depositCBox['values'] = ('Monthly', 'Bi-Yearly', 'Yearly') depositCBox.current(0) depositCBox.grid(column=3, row=2, pady=10, padx=10, sticky="ew") # The starting label startingLabel = ttk.Label(text="Starting with: $") startingLabel.grid(column=1, row=3, pady=10, padx=10, sticky="w") # The starting input startingInput = ttk.Entry() startingInput.grid(column=2, row=3, pady=10, padx=5, sticky="ew") # The starting combobox (just kidding this one doesn't have a combobox) outputBox = tk.Text(root, width=70, height=8, wrap="word") outputBox.insert(tk.END, "") outputBox.grid(column=1, row=4, columnspan=3, padx=10, pady=10, sticky="nsew") # grid config root.grid_columnconfigure(2, weight=1) root.grid_rowconfigure(4, weight=1) # HEEEEEEEEERRRRRRRRRREEEEEESSSSSSSS JUDY :3 def getFuckingLabelText(event=None): if depositCBox.get() == "Yearly": lengthLabelStringVar.set("Years") elif depositCBox.get() == "Monthly": lengthLabelStringVar.set("Months") else: lengthLabelStringVar.set("Half-years") depositCBox.bind("<>", getFuckingLabelText) # oh shit oh fuck it's the fucking calculation logic def calculateSavings(): try: length = int(lengthInput.get()) deposit = float(depositInput.get()) starting = float(startingInput.get()) currentSavings = starting outputBox.delete(1.0, "end") #lengthUnit = lengthCBox.get() depositFreq = depositCBox.get() if depositFreq == "Yearly": for x in range(1, length + 1): currentSavings += deposit if x == 1: outputBox.insert("end", f"After {x} year, you will have ${currentSavings:,.2f} saved.\n") else: outputBox.insert("end", f"After {x} years, you will have ${currentSavings:,.2f} saved.\n") outputBox.insert("end", f"\nTotal savings after {length} years: ${currentSavings:,.2f}\n") elif depositFreq == "Monthly": for x in range(1, length + 1): currentSavings += deposit if x == 1: outputBox.insert("end", f"After {x} month, you will have ${currentSavings:,.2f} saved.\n") else: outputBox.insert("end", f"After {x} months, you will have ${currentSavings:,.2f} saved.\n") outputBox.insert("end", f"\nTotal savings after {length} months: ${currentSavings:,.2f}\n") else: for x in range(1, length + 1): currentSavings += deposit if x == 1: outputBox.insert("end", f"After {x} half-year, you will have ${currentSavings:,.2f} saved.\n") else: outputBox.insert("end", f"After {x} half-years, you will have ${currentSavings:,.2f} saved.\n") outputBox.insert("end", f"\nTotal savings after {length} half-years: ${currentSavings:,.2f}\n") except ValueError: # error for when the stupid fucking user inputs text into a number box because they're users and of course they fucking will outputBox.delete(1.0, "end") outputBox.insert("end", "Error: Please enter valid numbers for Length, Deposit, and Starting Amount.\n") except Exception as e: # cause of course a user will somehow manage to fuck it up even more outputBox.delete(1.0, "end") outputBox.insert("end", f"An unexpected error occurred: {e}\n") calculateButton = ttk.Button(text="Calculate!", command=calculateSavings) calculateButton.grid(column=1, row=5, columnspan=3, pady=10) # makes the actual fucking UI load root.mainloop()