Feb-27-2024, 04:38 PM
(This post was last modified: Feb-27-2024, 04:38 PM by deanhystad.)
This is a low rent way of doing what you want with the dialog.
import ttkbootstrap as ttk def get_dates(start=None, end=None, format="%Y/%m/%d"): """Draw dialog for selecting start and end dates.""" root = ttk.Window() root.title("Enter Dates") # If window is destroyed we cannot get the date values. # Override what the close button does. root.wm_protocol("WM_DELETE_WINDOW", root.quit) frame = ttk.Frame(root) frame.pack(padx=10, pady=10) ttk.Label(frame, text="Start Date").grid(row=0, column=0, pady=(0, 10)) start = ttk.DateEntry(frame, start_date=start, dateformat=format) start.grid(row=0, column=1, pady=(0, 10)) ttk.Label(frame, text="End Date").grid(row=1, column=0, pady=(0, 10)) end = ttk.DateEntry(frame, start_date=end, dateformat=format) end.grid(row=1, column=1, pady=(0, 10)) done = ttk.Button(frame, text="Done", command=root.quit) done.grid(row=2, column=0, columnspan=2, sticky="news") # Wait until the done button or close decoration are pressed. root.mainloop() # Get dates before destroying the window. start = start.entry.get() end = end.entry.get() root.destroy() return start, end print(get_dates())The script that used the dialog is just a print() statement, but I think you can see how the dialog would get used in a longer script.