ttkbootstrap icon indicating copy to clipboard operation
ttkbootstrap copied to clipboard

DateEntry configure() doesn't change startdate in DateEntry field

Open windir19 opened this issue 1 year ago • 2 comments

Desktop (please complete the following information):

ttkbootstrap v1.10.1 OS: Windows

Describe the bug

I am trying to write a script that when a button is click will find a datetime somewhere and update it into the ttkbootstrap DateEntry. tkinter uses set_date() to change what is shown in the field but it seems that doesn't exist for ttkbootstrap version of DateEntry. I asked a question about how to set the DateEntry with tkinter in the github forums for ttkbootstrap and was told by @rdbende that I should use .configure(startdate=datetimevalue)

@rdbende mentioned it looks like a bug because he couldn't get it to. When I run it I don't get an error in the console but it doesn't seem to change the date listed in the field so it doesn't work for me either.

I want to iterate that my goal is NOT to set the "startdate" when I create the button in the GUI but to have it set upon an action like with a button press.

To Reproduce

I wrote this small code to explain what I am trying to do.

import ttkbootstrap as ttk
import datetime

root = ttk.Window()

some_date = datetime.datetime.fromisoformat("2022-11-11")

date_chooser = ttk.DateEntry(root, startdate=datetime.datetime.today())
date_chooser.pack()

set_date_btn = ttk.Button(root, text="Set Date", command=lambda: date_chooser.configure(startdate=some_date))
set_date_btn.pack()

root.mainloop()

Expected behavior

When you click the button "Set Date" button I would expect the value of the DateEntry field to change to whatever datetime I pull from a source (some_date in the code as an example).

Screenshots

No response

Additional context

If there is a different way to set the date value in DateEntry from an action, I would love to know or see it in the documentation for ttkbootstrap. Thank you.

windir19 avatar Oct 13 '23 15:10 windir19

atkinter uses set_date() to change what is shown in the field but it seems that doesn't exist for ttkbootstrap version of DateEntry

Worth noting that what's here referred to as tkinter's date entry is the DateEntry widget from the tkcalendar package. I'd also like to add, that while using .configure() is the more tkinter-ic way, for compatibility with tkcalendar it would be niceto also add a set_date method.

rdbende avatar Oct 13 '23 16:10 rdbende

My work around was to create a new DateEntry with the startdate configured to be the new date that I wanted it to change to.

Megsman avatar Dec 28 '23 03:12 Megsman