The wckCalendar Widget
Fredrik Lundh | September 2007
The wckCalendar module is a simple calendar widget for Tkinter and other WCK-compatible toolkits, based on Python’s standard calendar module.
(the buttons shown in this screenshot are not part of the widget itself)
Installation #
To use this widget, you need Tkinter and the Widget Construction Kit extension.
The widget itself is available from the effbot.org sandbox:
The widget has been tested with Python 2.5 and WCK 1.1. The current release is mostly unstyled, and doesn’t support keyboard navigation. Contributions are welcome.
Usage #
Using the widget is easy; just create the widget, and either call getselection to get the selected date when needed, or register a command callback to keep track of changes.
import wckCalendar root = Tkinter.Tk() def echo(): print calendar.getselection() calendar = wckCalendar.Calendar(root, command=echo) calendar.pack() mainloop()
By default, the widget shows the current month and pre-selects the current day. To change the month, call setdate. To change the selection, call setselection. Both methods take a datetime.date object.