def send(): global entry_today try: mood = int(e1.get()) except ValueError: print("Mood needs to be a real number from 0-100.") e1.delete(0, END) if int(mood) > 100: mood = "100" if int(mood) < 0: mood = "00" if int(mood) < 10 and not 0: mood = "0" + str(mood) today = InOut.Day( mood, datetime.date.today().strftime('%d-%m-%y').replace(",", ""), t1.get("0.0", END).replace('\n', " ")) # remove \n in textArea for storage in file. if entry_today: list_of_days[len(list_of_days) - 1] = today InOut.write_list("daysGUI.txt", list_of_days) else: InOut.add_today_to_file("daysGUI.txt", today) entry_today = TRUE e1.config(state="readonly") t1.config(state="disabled") b1.config(state="disabled") b2.config(state="normal") l3.config( text= "\t\tSaved today's entry correctly.\n \t\t If you wish to edit it press EDIT." ) global current_day current_day = today
from tkinter import * from tkinter.messagebox import showinfo import datetime import InOut import Calculations # check if today has already been registered entry_today = FALSE current_day = InOut.Day(50, datetime.date.today().strftime('%d-%m-%y'), "") try: list_of_days = InOut.read_from_file("daysGUI.txt") if list_of_days[len(list_of_days) - 1].date == datetime.date.today().strftime('%d-%m-%y'): entry_today = TRUE current_day = list_of_days[len(list_of_days) - 1] except FileNotFoundError: print("There's no file for days.") # window params window = Tk() window.title("Mood GUI") window.minsize(500, 470) window.maxsize(500, 470) # frames f1 = Frame(window) f2 = Frame(window) f3 = Frame(window) f4 = Frame(window) # elements such as labels and entries l1 = Label(f1, text=" Mood(1-100):\t")