METADATA 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. Metadata-Version: 2.1
  2. Name: tkcalendar
  3. Version: 1.6.1
  4. Summary: Calendar and DateEntry widgets for Tkinter
  5. Home-page: https://github.com/j4321/tkcalendar
  6. Author: Juliette Monsel
  7. Author-email: j_4321@protonmail.com
  8. License: GPLv3
  9. Keywords: tkinter,calendar,date
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: Intended Audience :: Developers
  13. Classifier: Topic :: Software Development :: Widget Sets
  14. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  15. Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Programming Language :: Python :: 3.4
  18. Classifier: Programming Language :: Python :: 3.5
  19. Classifier: Programming Language :: Python :: 3.6
  20. Classifier: Operating System :: OS Independent
  21. Requires-Dist: babel
  22. ##########
  23. tkcalendar
  24. ##########
  25. |Release| |Travis| |Appveyor| |Codecov| |Windows| |Linux| |Mac| |License| |Doc|
  26. tkcalendar is a python module that provides the Calendar and DateEntry widgets for Tkinter.
  27. The DateEntry widget is similar to a Combobox, but the drop-down is not a list but a Calendar to select a date.
  28. Events can be displayed in the Calendar with custom colors and a tooltip displays the event list for a given day.
  29. tkcalendar is compatible with both Python 2 and Python 3.
  30. It supports many locale settings (e.g. 'fr_FR', 'en_US', ..) and the colors are customizable.
  31. The documentation is also available here: https://tkcalendar.readthedocs.io
  32. .. contents:: Table of Contents
  33. Requirements
  34. ============
  35. - Linux, Windows, OSX
  36. - Python 3
  37. And the python packages:
  38. - tkinter (included in the python distribution for Windows)
  39. - `babel <https://pypi.org/project/babel/>`_
  40. Installation
  41. ============
  42. - Ubuntu: use the PPA `ppa:j-4321-i/ppa <https://launchpad.net/~j-4321-i/+archive/ubuntu/ppa>`__
  43. ::
  44. $ sudo add-apt-repository ppa:j-4321-i/ppa
  45. $ sudo apt-get update
  46. $ sudo apt-get install python3-tkcalendar
  47. - Archlinux:
  48. The package is available on `AUR <https://aur.archlinux.org/packages/python-tkcalendar>`__
  49. - With pip:
  50. ::
  51. $ pip install tkcalendar
  52. Documentation
  53. =============
  54. Calendar widget
  55. ---------------
  56. Syntax
  57. ~~~~~~
  58. ::
  59. Calendar(master=None, **kw)
  60. Widget keyword options
  61. ~~~~~~~~~~~~~~~~~~~~~~
  62. * Standard options
  63. cursor : str
  64. cursor to display when the pointer is in the widget
  65. font : str such as "Arial 20 bold" or a Tkinter Font instance
  66. font of the calendar
  67. borderwidth : int
  68. width of the border around the calendar
  69. state : str
  70. "normal" or "disabled" (unresponsive widget)
  71. * Widget-specific options:
  72. year : int
  73. intinitially displayed year, default is current year.
  74. month : int
  75. initially displayed month, default is current month.
  76. day : int
  77. initially selected day, if month or year is given but not day, no initial selection, otherwise, default is today.
  78. firstweekday : "monday" or "sunday"
  79. first day of the week
  80. weekenddays : list
  81. days to be displayed as week-end days given as a list of integers corresponding to the number of the day in the week (e.g. [6, 7] for the last two days of the week).
  82. mindate : datetime.date or datetime.datetime (default is None)
  83. minimum allowed date
  84. maxdate : datetime.date or datetime.datetime (default is None)
  85. maximum allowed date
  86. showweeknumbers : bool (default is True)
  87. whether to display week numbers.
  88. showothermonthdays : bool (default is True)
  89. whether to display the last days of the previous month and the first of the next month.
  90. locale : str
  91. locale to use, e.g. 'en_US'
  92. date_pattern : str
  93. date pattern used to format the date as a string. The default pattern used
  94. is ``babel``'s short date format in the calendar's locale.
  95. A valid pattern is a combination of 'd', 'm' and 'y' separated by
  96. non letter characters to indicate how and in which order the
  97. year, month and day should be displayed.
  98. = =========================================================================
  99. d 'd' for the day of month number without padding, 'dd' for a two-digit day
  100. m 'm' for the month number without padding, 'mm' for a two-digit month
  101. y 'yy' for the two last digits of the year, any other number of 'y's for
  102. the full year with an extra padding of zero if it has less digits than
  103. the number of 'y's.
  104. = =========================================================================
  105. Examples for ``datetime.date(2019, 7, 1)``
  106. - 'y-mm-dd' → '2019-07-01'
  107. - 'm/d/yy' → '7/1/19'
  108. selectmode : "none" or "day" (default)
  109. whether the user can change the selected day with a mouse click.
  110. textvariable : StringVar
  111. connect the currently selected date to the variable.
  112. * Style options:
  113. background :
  114. background color of calendar border and month/year name
  115. foreground :
  116. foreground color of month/year name
  117. disabledbackground : str
  118. background color of calendar border and month/year name in disabled state
  119. disabledforeground : str
  120. foreground color of month/year name in disabled state
  121. bordercolor :
  122. day border color
  123. headersbackground :
  124. background color of day names and week numbers
  125. headersforeground :
  126. foreground color of day names and week numbers
  127. selectbackground :
  128. background color of selected day
  129. selectforeground :
  130. foreground color of selected day
  131. disabledselectbackground :
  132. background color of selected day in disabled state
  133. disabledselectforeground :
  134. foreground color of selected day in disabled state
  135. normalbackground :
  136. background color of normal week days
  137. normalforeground :
  138. foreground color of normal week days
  139. weekendbackground :
  140. background color of week-end days
  141. weekendforeground :
  142. foreground color of week-end days
  143. othermonthforeground :
  144. foreground color of normal week days belonging to the previous/next month
  145. othermonthbackground :
  146. background color of normal week days belonging to the previous/next month
  147. othermonthweforeground :
  148. foreground color of week-end days belonging to the previous/next month
  149. othermonthwebackground :
  150. background color of week-end days belonging to the previous/next month
  151. disableddaybackground :
  152. background color of days in disabled state
  153. disableddayforeground :
  154. foreground color of days in disabled state
  155. * Tooltip options (for calevents):
  156. tooltipforeground :
  157. tooltip text color
  158. tooltipbackground :
  159. tooltip background color
  160. tooltipalpha : float
  161. tooltip opacity between 0 and 1
  162. tooltipdelay : int
  163. delay in ms before displaying the tooltip
  164. Virtual Events
  165. ~~~~~~~~~~~~~~
  166. * A ``<<CalendarSelected>>`` event is generated each time the user selects a day with the mouse.
  167. * A ``<<CalendarMonthChanged>>`` event is generated each time the user changes the displayed month.
  168. Widget methods
  169. ~~~~~~~~~~~~~~
  170. * Standard methods:
  171. - methods common to all tkinter widgets
  172. (more details `here <http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/universal.html>`__)
  173. - methods common to all ttk widgets
  174. (more details `here <http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Widget.html>`__)
  175. * Widget-Specific methods:
  176. calevent_cget(ev_id, option) :
  177. Return value of given option for the event *ev_id*.
  178. calevent_configure(ev_id, \*\*kw) :
  179. Return value of given option for the event *ev_id*.
  180. calevent_create(date, text, tags=[]) :
  181. Add new event in calendar and return event id.
  182. Options:
  183. *date*: ``datetime.date`` or ``datetime.datetime`` instance.
  184. *text*: text to put in the tooltip associated to date.
  185. *tags*: list of tags to apply to the event. The last tag determines the way the event is displayed.
  186. If there are several events on the same day, the lowest one (on the tooltip list)
  187. which has tags determines the colors of the day.
  188. calevent_lower(ev_id, below=None) :
  189. Lower event *ev_id* in tooltip event list.
  190. *below*: put event below given one, if below is None, put it at the bottom of tooltip event list.
  191. The day's colors are determined by the last tag of the lowest event which has tags.
  192. calevent_raise(ev_id, above=None) :
  193. Raise event *ev_id* in tooltip event list.
  194. *above*: put *ev_id* above given one, if above is None, put it on top of tooltip event list.
  195. The day's colors are determined by the last tag of the lowest event which has tags.
  196. calevent_remove(\*ev_ids, \*\*kw) :
  197. Remove events from calendar.
  198. Arguments: event ids to remove or 'all' to remove them all.
  199. Keyword arguments: *tag*, *date*. They are taken into account only if no id is given.
  200. Remove all events with given tag on given date. If only date is given,
  201. remove all events on date and if only tag is given, remove all events with tag.
  202. get_date() :
  203. If selectmode is 'day', return the string corresponding to the selected date in the
  204. ``Calendar`` locale, otherwise return ``""``.
  205. get_calevents(date=None, tag=None) :
  206. Return event ids of events with given tag and on given date.
  207. If only *date* is given, return event ids of all events on date.
  208. If only *tag* is given, return event ids of all events with tag.
  209. If both options are None, return all event ids.
  210. get_displayed_month() :
  211. Return the currently displayed month in the form of a (month, year) tuple.
  212. see(date) :
  213. Display the month in which *date* is.
  214. *date*: ``datetime.date`` or ``datetime.datetime`` instance.
  215. selection_clear() :
  216. Clear the selection.
  217. selection_get() :
  218. If selectmode is 'day', return the selected date as a ``datetime.date``
  219. instance, otherwise return ``None``.
  220. selection_set(self, date) :
  221. If selectmode is 'day', set the selection to *date* where *date* can be either a ``datetime.date``
  222. instance or a string corresponding to the date format ``"%x"`` in the ``Calendar``
  223. locale. Does nothing if selectmode is ``"none"``.
  224. tag_cget(tag, option) :
  225. Return the value of the tag's option.
  226. tag_config(self, tag, \*\*kw) :
  227. Configure *tag*.
  228. Keyword options: *foreground*, *background* (of the day in the calendar)
  229. tag_delete(tag) :
  230. Delete given tag and remove it from all events.
  231. tag_names() :
  232. Return tuple of existing tags.
  233. DateEntry widget
  234. ----------------
  235. Date selection entry with drop-down calendar.
  236. Syntax
  237. ~~~~~~
  238. ::
  239. DateEntry(master=None, **kw)
  240. Widget keyword options
  241. ~~~~~~~~~~~~~~~~~~~~~~
  242. * Keyword options of ``Calendar`` to configure the drop-down calendar
  243. The Calendar option *cursor* has been renamed *calendar_cursor* to
  244. avoid name clashes with the corresponding ``ttk.Entry`` option.
  245. * Keyword options of ``ttk.Entry``
  246. By default, 'validate' is set to 'focusout' and 'validatecommand' is configured so that each
  247. time the widget looses focus, if the content is not a valid date (in locale format '%x'),
  248. it is reset to the previous valid date.
  249. The widget style is set to 'DateEntry'. A custom style inheritting from 'DateEntry'
  250. can be created by naming it '<style name>.DateEntry'
  251. * Virtual Events
  252. A ``<<DateEntrySelected>>`` event is generated each time the user selects a date.
  253. Widget methods
  254. ~~~~~~~~~~~~~~
  255. * Standard methods:
  256. - methods common to all tkinter widgets
  257. (more details `here <http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/universal.html>`__)
  258. - methods common to all ttk widgets
  259. (more details `here <http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Widget.html>`__)
  260. - methods of the ``Entry`` widget
  261. (more details `here <http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/entry.html>`__)
  262. * Widget-Specific methods:
  263. drop_down() :
  264. Display or withdraw the drop-down calendar depending on its current state.
  265. get_date() :
  266. Return the selected date as a ``datetime.date`` instance.
  267. set_date(self, date) :
  268. Set the value of the DateEntry to *date* where *date* can be either a ``datetime.date``
  269. instance or a string corresponding to the date format `"%x"` in the `Calendar` locale.
  270. HowTos
  271. ======
  272. Widget styling, Pyinstaller, Custom date formatting: see https://tkcalendar.readthedocs.io/en/stable/howtos.html
  273. Changelog
  274. =========
  275. - tkcalendar 1.6.1
  276. * Fix typo in ``DateEntry`` that lead to position issues for the drop-down (`#66 <https://github.com/j4321/tkcalendar/issues/66>`_)
  277. - tkcalendar 1.6.0
  278. * Fix vanishing of the drop-down calendar on any click when grab_set is used
  279. * Fix ``DateEntry`` cursor customization which had no effect
  280. * Temporarily fix `python issue 38661 <https://bugs.python.org/issue38661>`_ (`#61 <https://github.com/j4321/tkcalendar/issues/61>`_)
  281. * Add *calendar_cursor* option to change the cursor on the ``Calendar`` of the ``DateEntry`` (`#55 <https://github.com/j4321/tkcalendar/issues/55>`_)
  282. * Fix always on top bug using resizable (`#62 <https://github.com/j4321/tkcalendar/issues/62>`_)
  283. - tkcalendar 1.5.1
  284. * Fix calendar drop-down not in front issue if window has the ``-topmost`` attribute in Windows (`#49 <https://github.com/j4321/tkcalendar/issues/49>`_)
  285. * Make ``Calendar.config()`` and ``DateEntry.config()`` accept a dictionary like standard tkinter widgets
  286. * Fix calendar not hiding when clicking again on ``DateEntry`` drop-down button in Windows (`#51 <https://github.com/j4321/tkcalendar/issues/51>`_)
  287. * Fix *maxdate* disabled while it sould be the latest allowed date (`#50 <https://github.com/j4321/tkcalendar/issues/50>`_)
  288. - tkcalendar 1.5.0
  289. * Add *disabledforeground* and *disabledbackground* options to further customize
  290. the disabled state appearance of the ``Calendar``
  291. * Add *maxdate* and *mindate* options to set an allowed date range for date selection
  292. * Add *weekenddays* option to choose the days colored as week-end days (`#37 <https://github.com/j4321/tkcalendar/issues/37>`_)
  293. * Add *date_pattern* option to customize the date format
  294. * Add ``Calendar.see()`` method to make sure a date is visible
  295. * Make ``Calendar.selection_clear()`` actually clear the selection
  296. * Make *locale* option editable after the creation of the Calendar
  297. * Fix ``ValueError`` when retrieving default locale
  298. * Fix date parsing error in Swedish locale and some others (`#44 <https://github.com/j4321/tkcalendar/issues/44>`_)
  299. * Improve compliance with ttk themes by making the ``DateEntry`` look like a ``ttk.Combobox`` (`#42 <https://github.com/j4321/tkcalendar/issues/42>`_)
  300. * Fix high CPU issues in Windows (`#36 <https://github.com/j4321/tkcalendar/issues/36>`_)
  301. - tkcalendar 1.4.0
  302. * Add ``<<CalendarMonthChanged>>`` virtual event to the ``Calendar`` widget
  303. * Add ``get_displayed_month()`` method to the ``Calendar`` widget
  304. * Add *showothermonthdays* option to show/hide the last and first days of the previous and next months
  305. * Fix display of events for January days showing on December page and conversely
  306. - tkcalendar 1.3.1
  307. * Fix bug in day selection when firstweekday is 'sunday' (`#28 <https://github.com/j4321/tkcalendar/issues/28>`_)
  308. - tkcalendar 1.3.0
  309. * No longer set locale globally to avoid conflicts between several instances, use ``babel`` module instead (`#15 <https://github.com/j4321/tkcalendar/issues/15>`_)
  310. * Add *showwekknumbers* option to show/hide week numbers (`#18 <https://github.com/j4321/tkcalendar/issues/18>`_)
  311. * Add *firstweekday* option to choose first week day between 'monday' and 'sunday' (`#25 <https://github.com/j4321/tkcalendar/issues/25>`_)
  312. * Make ``DateEntry`` compatible with more ttk themes, especially OSX default theme (`#16 <https://github.com/j4321/tkcalendar/issues/16>`_)
  313. * Add possibility to display special events (like birthdays, ..) in the calendar
  314. The events are displayed with colors defined by tags and the event description is displayed in a tooltip
  315. (see documentation) (`#19 <https://github.com/j4321/tkcalendar/issues/19>`_)
  316. - tkcalendar 1.2.1
  317. * Fix ``ValueError`` in ``DateEntry`` with Python 3.6.5 (`#13 <https://github.com/j4321/tkcalendar/issues/13>`_)
  318. - tkcalendar 1.2.0
  319. * Add *textvariable* option to ``Calendar`` (`#6 <https://github.com/j4321/tkcalendar/issues/6>`_)
  320. * Add *state* ('normal' or 'disabled') option to Calendar
  321. * Add *disabledselectbackground*, *disabledselectforeground*,
  322. *disableddaybackground* and *disableddayforeground* options to configure colors
  323. when ``Calendar`` is disabled
  324. * Fix ``DateEntry`` behavior in readonly mode
  325. * Make ``Calendar.selection_get()`` always return a ``datetime.date``
  326. - tkcalendar 1.1.5
  327. * Fix endless triggering of ``<<ThemeChanged>>`` event in ``DateEntry`` (`#9 <https://github.com/j4321/tkcalendar/issues/9>`_)
  328. - tkcalendar 1.1.4
  329. * Fix error in January due to week 53
  330. * Fix ``DateEntry`` for ttk themes other than 'clam' (`#3 <https://github.com/j4321/tkcalendar/issues/3>`_)
  331. - tkcalendar 1.1.3
  332. * Make ``DateEntry`` support initialisation with partial dates (e.g. just year=2010)
  333. * Improve handling of wrong year-month-day combinations
  334. - tkcalendar 1.1.2
  335. * Fix bug after destroying a ``DateEntry``
  336. * Fix bug in style and font
  337. - tkcalendar 1.1.1
  338. * Fix bug when content of ``DateEntry`` is not a valid date
  339. - tkcalendar 1.1.0
  340. * Fix display of the first days of the next month
  341. * Increment year when going from December to January
  342. * Add widget ``DateEntry``: date selection entry with drop-down calendar
  343. * Add *borderwidth*, *othermonthbackground*, *othermonthweforeground*,
  344. *othermonthwebackground* options to further customize the
  345. appearance of the calendar
  346. - tkcalendar 1.0.0
  347. * Initial version
  348. Example
  349. =======
  350. .. code:: python
  351. from tkcalendar import Calendar, DateEntry
  352. try:
  353. import tkinter as tk
  354. from tkinter import ttk
  355. except ImportError:
  356. import Tkinter as tk
  357. import ttk
  358. def example1():
  359. def print_sel():
  360. print(cal.selection_get())
  361. cal.see(datetime.date(year=2016, month=2, day=5))
  362. top = tk.Toplevel(root)
  363. import datetime
  364. today = datetime.date.today()
  365. mindate = datetime.date(year=2018, month=1, day=21)
  366. maxdate = today + datetime.timedelta(days=5)
  367. print(mindate, maxdate)
  368. cal = Calendar(top, font="Arial 14", selectmode='day', locale='en_US',
  369. mindate=mindate, maxdate=maxdate, disabledforeground='red',
  370. cursor="hand1", year=2018, month=2, day=5)
  371. cal.pack(fill="both", expand=True)
  372. ttk.Button(top, text="ok", command=print_sel).pack()
  373. def example2():
  374. top = tk.Toplevel(root)
  375. cal = Calendar(top, selectmode='none')
  376. date = cal.datetime.today() + cal.timedelta(days=2)
  377. cal.calevent_create(date, 'Hello World', 'message')
  378. cal.calevent_create(date, 'Reminder 2', 'reminder')
  379. cal.calevent_create(date + cal.timedelta(days=-2), 'Reminder 1', 'reminder')
  380. cal.calevent_create(date + cal.timedelta(days=3), 'Message', 'message')
  381. cal.tag_config('reminder', background='red', foreground='yellow')
  382. cal.pack(fill="both", expand=True)
  383. ttk.Label(top, text="Hover over the events.").pack()
  384. def example3():
  385. top = tk.Toplevel(root)
  386. ttk.Label(top, text='Choose date').pack(padx=10, pady=10)
  387. cal = DateEntry(top, width=12, background='darkblue',
  388. foreground='white', borderwidth=2, year=2010)
  389. cal.pack(padx=10, pady=10)
  390. root = tk.Tk()
  391. ttk.Button(root, text='Calendar', command=example1).pack(padx=10, pady=10)
  392. ttk.Button(root, text='Calendar with events', command=example2).pack(padx=10, pady=10)
  393. ttk.Button(root, text='DateEntry', command=example3).pack(padx=10, pady=10)
  394. root.mainloop()
  395. .. |Release| image:: https://badge.fury.io/py/tkcalendar.svg
  396. :alt: Latest Release
  397. :target: https://pypi.org/project/tkcalendar/
  398. .. |Linux| image:: https://img.shields.io/badge/platform-Linux-blue.svg
  399. :alt: Platform
  400. .. |Windows| image:: https://img.shields.io/badge/platform-Windows-blue.svg
  401. :alt: Platform
  402. .. |Mac| image:: https://img.shields.io/badge/platform-Mac-blue.svg
  403. :alt: Platform
  404. .. |Travis| image:: https://travis-ci.org/j4321/tkcalendar.svg?branch=master
  405. :target: https://travis-ci.org/j4321/tkcalendar
  406. :alt: Travis CI Build Status
  407. .. |Appveyor| image:: https://ci.appveyor.com/api/projects/status/9a5bi9ewvccdmo3a/branch/master?svg=true
  408. :target: https://ci.appveyor.com/project/j4321/tkcalendar/branch/master
  409. :alt: Appveyor Build Status
  410. .. |Codecov| image:: https://codecov.io/gh/j4321/tkcalendar/branch/master/graph/badge.svg
  411. :target: https://codecov.io/gh/j4321/tkcalendar
  412. :alt: Code coverage
  413. .. |License| image:: https://img.shields.io/github/license/j4321/tkcalendar.svg
  414. :target: https://www.gnu.org/licenses/gpl-3.0.en.html
  415. :alt: License
  416. .. |Doc| image:: https://readthedocs.org/projects/tkcalendar/badge/?version=latest
  417. :target: https://tkcalendar.readthedocs.io/en/latest/?badge=latest
  418. :alt: Documentation Status