I am trying to define a function (which I have called "nextTime") that allows me to read the date that the user puts in the Entry (or today's date) and modify it with a "Next day" button.
The date I want to be written in the dd / mm / yyyy format.
I guess what does not work is the FechaEntry.get()
in the function.
This is the code:
import time
import datetime
from tkinter import *
format="%d/%m/%Y"
today = datetime.date.today()
unDia=datetime.timedelta(days=1)
fecha=today.strftime(format)
def diaSiguiente():
FechaActual=FechaEntry.get()
FechaEntry.delete(0, END)
NuevaFecha=FechaActual + unDia
FechaEntry.insert(0, NuevaFecha)
root=Tk()
FechaEntry=Entry(root)
FechaEntry.grid(row=0, column=1)
labelFecha=Label(text='Data')
labelFecha.grid(row=0, column=0)
botonDiaSiguiente=Button(text='Día siguiente', command=diaSiguiente)
botonDiaSiguiente.grid(row=0, column=2)
FechaEntry.insert(0, fecha)
root.mainloop()