israel-dryer / ttkbootstrap

A supercharged theme extension for tkinter that enables on-demand modern flat style themes inspired by Bootstrap.
MIT License
1.79k stars 363 forks source link

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

Open windir19 opened 9 months ago

windir19 commented 9 months ago

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.

rdbende commented 9 months ago

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.

Megsman commented 6 months ago

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.