Я делаю проект, чтобы создать программу с графическим интерфейсом для пользователей, чтобы рассчитать оставшиеся дни до достижения события. У меня возникла проблема с вычислением оставшейся даты между датой события пользователя и сейчас.
from tkinter import *
import datetime
def save_info():
eventname_info = eventname.get()
eventyear_info = eventyear.get()
eventyear_info = str(eventyear_info)
eventmonth_info = eventmonth.get()
eventmonth_info = str(eventmonth_info)
eventday_info = eventday.get()
eventday_info = str(eventday_info)
print(eventname_info, eventyear_info, eventmonth_info, eventday_info)
def calculate():
def combine_funs():
save_info()
calculate()
file = open("actualdata.txt", "w")
file.write(eventname_info)
file.write(eventyear_info)
file.write(eventmonth_info)
file.write(eventday_info)
file.close()
print(" Event ", eventname_info, " has been record successfully")
eventname_entry.delete(0, END)
eventyear_entry.delete(0, END)
eventmonth_entry.delete(0, END)
eventday_entry.delete(0, END)
screen = Tk()
screen.geometry("500x500")
screen.title("Welcome to the Countdown module")
heading = Label(text = "Welcome to the Countdown module", width = "500", height = "2")
heading.pack()
eventname_text = Label(text = "Event name:")
eventyear_text = Label(text = "Event year:")
eventmonth_text = Label(text = "Event month:")
eventday_text = Label(text = "Event day:")
eventname_text.place(x = 15, y = 70)
eventyear_text.place(x = 15, y = 140)
eventmonth_text.place(x = 15, y = 210)
eventday_text.place(x = 15, y = 280)
eventname = StringVar()
eventyear = IntVar()
eventmonth = IntVar()
eventday = IntVar()
eventname_entry = Entry(textvariable = eventname, width = "30")
eventyear_entry = Entry(textvariable = eventyear, width = "30")
eventmonth_entry = Entry(textvariable = eventmonth, width = "30")
eventday_entry = Entry(textvariable = eventday,width = "30")
eventname_entry.place(x = 15, y = 100)
eventyear_entry.place(x = 15, y = 170)
eventmonth_entry.place(x = 15, y = 240)
eventday_entry.place(x = 15, y = 310)
addbutton = Button(screen,text = "Add timer", width = "30", height = "2", command = combine_funs,)
addbutton.place(x = 15, y = 390)
Окончательным результатом будет название события и оставшиеся дни.