I am making a Python program that uses the DateEntry widget in Tkinter. However, when I run the program, I can't see the calendar. My code:
import tkinter as tk
from tkinter import ttk
from tkcalendar import DateEntry # Make sure to install tkcalendar using: pip install tkcalendar
def on_date_select():
selected_date = cal.get_date()
print(f"Selected date: {selected_date}")
root = tk.Tk()
root.title("Datepicker Example")
# Create a Calendar
cal = DateEntry(root, width=12, background='darkblue', foreground='white', borderwidth=2)
cal.pack(padx=10, pady=10)
# Create a button to get the selected date
btn_get_date = ttk.Button(root, text="Get Selected Date", command=on_date_select)
btn_get_date.pack(pady=10)
root.mainloop()
I have tried many solutions on the internet all to no avail. How do I fix this problem?
Note: I’m using m1 MacBook Air