Skip to main content

Calendar and DateEntry widgets for Tkinter

Project description

tkcalendar

tkcalendar is a python module that provides the Calendar and DateEntry widgets for Tkinter. The DateEntry widget is similar to a Combobox, but the drop-down is not a list but a Calendar to select a date. tkcalendar is compatible with both Python 2 and Python 3. It support all locale settings supported by the system and the colors are customizable.

Requirements

  • Linux, Windows, Mac

  • Python 2 or 3 with tkinter + ttk (default for Windows but not for Linux)

Installation

  • Ubuntu: use the PPA ppa:j-4321-i/ppa

    $ sudo add-apt-repository ppa:j-4321-i/ppa
    $ sudo apt-get update
    $ sudo apt-get install python(3)-tkcalendar
  • Archlinux:

    The package is available on AUR

  • With pip:

$ pip install tkcalendar

Documentation

  • Calendar widget

    Syntax:

    Calendar(master=None, **kw)

    Widget keyword options:

    • Standard options

      cursor: cursor to display when the pointer is in the widget

      font: font of the calendar, can be a string such as “Arial 20 bold” or a Tkinter Font instance

      borderwidth: width of the border around the calendar (integer)

    • Widget-Specific Options

      year, month: initially displayed month, default is current month

      day: initially selected day, if month or year is given but not day, no initial selection, otherwise, default is today

      locale: locale to use, e.g. “fr_FR” for a French calendar

      selectmode: “none” or “day” (default) define whether the user can change the selected day with a mouse click

      background: calendar border and month/year name background color

      foreground: month/year name foreground color

      bordercolor: day border color

      selectbackground: selected day background color

      selectforeground: selected day foreground color

      normalbackground: normal week days background color

      normalforeground: normal week days foreground color

      othermonthforeground: foreground color for normal week days belonging to the previous/next month

      othermonthbackground: background color for normal week days belonging to the previous/next month

      othermonthweforeground: foreground color for week-end days belonging to the previous/next month

      othermonthwebackground: background color for week-end days belonging to the previous/next month

      weekendbackground: week-end days background color

      weekendforeground: week-end days foreground color

      headersbackground: day names and week numbers background color

      headersforeground: day names and week numbers foreground color

    • Virtual Events

      A <<CalendarSelected>> event is generated each time the user selects a day with the mouse.

  • DateEntry widget

    Date selection entry with drop-down calendar.

    Syntax:

    DateEntry(master=None, **kw)

    Widget keyword options:

    • Keyword options of Calendar to configure the drop-down calendar

    • Keyword options of ttk.Entry

      By default, ‘validate’ is set to ‘focusout’ and ‘validatecommand’ is configured so that each time the widget looses focus, if the content is not a valid date (in locale format ‘%x’), it is reset to the previous valid date.

      The widget style is set to ‘DateEntry’. A custom style inheritting from ‘DateEntry’ can be created by naming it ‘<style name>.DateEntry’

    • Virtual Events

      A <<DateEntrySelected>> event is generated each time the user selects a date.

Changelog

  • tkcalendar 1.1.2

    • Fix bug after destroying a DateEntry

    • Fix bug in style and font

  • tkcalendar 1.1.1

    • Fix bug when content of DateEntry is not a valid date

  • tkcalendar 1.1.0

    • Bug fix:

      • Fix display of the first days of the next month

      • Increment year when going from december to january

    • New widget:

      • DateEntry, date selection entry with drop-down calendar

    • New options in Calendar:

      • borderwidth: width of the border around the calendar (integer)

      • othermonthbackground: background color for normal week days belonging to the previous/next month

      • othermonthweforeground: foreground color for week-end days belonging to the previous/next month

      • othermonthwebackground: background color for week-end days belonging to the previous/next month

  • tkcalendar 1.0.0

    • Initial version

Example

try:
    import tkinter as tk
    from tkinter import ttk
except ImportError:
    import Tkinter as tk
    import ttk

from tkcalendar import Calendar, DateEntry

def example1():
    def print_sel():
        print(cal.selection_get())

    top = tk.Toplevel(root)

    cal = Calendar(top,
                   font="Arial 14", selectmode='day',
                   cursor="hand1", year=2018, month=2, day=5)
    cal.pack(fill="both", expand=True)
    ttk.Button(top, text="ok", command=print_sel).pack()

def example2():
    top = tk.Toplevel(root)

    ttk.Label(top, text='Choose date').pack(padx=10, pady=10)

    cal = DateEntry(top, width=12, background='darkblue',
                    foreground='white', borderwidth=2)
    cal.pack(padx=10, pady=10)

root = tk.Tk()
s = ttk.Style(root)
s.theme_use('clam')

ttk.Button(root, text='Calendar', command=example1).pack(padx=10, pady=10)
ttk.Button(root, text='DateEntry', command=example2).pack(padx=10, pady=10)

root.mainloop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkcalendar-1.1.2.tar.gz (27.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tkcalendar-1.1.2-py3.6.egg (23.5 kB view details)

Uploaded Egg

tkcalendar-1.1.2-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

tkcalendar-1.1.2-py2.7.egg (23.7 kB view details)

Uploaded Egg

tkcalendar-1.1.2-py2-none-any.whl (14.3 kB view details)

Uploaded Python 2

File details

Details for the file tkcalendar-1.1.2.tar.gz.

File metadata

  • Download URL: tkcalendar-1.1.2.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tkcalendar-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e4e8f6fd80b6cb61202b6b54e56a55b0915f302c4b2c174e9355f8a8c28d4da9
MD5 a6216ac148e9a67690064b96508e1a58
BLAKE2b-256 39866e1a14907e1690bf4175930714d7679a9da64960a39f301708c811d893f4

See more details on using hashes here.

File details

Details for the file tkcalendar-1.1.2-py3.6.egg.

File metadata

File hashes

Hashes for tkcalendar-1.1.2-py3.6.egg
Algorithm Hash digest
SHA256 27a4cccd0c2be1e3173dad3105373fc0e1a2e98489ef5eaa0dd5b02722ceda00
MD5 4f9d8e5b589cb448157acfe3f47267d8
BLAKE2b-256 bf36d1cabf45b1df08e6552f1f4a126c6d176c32bad5b8a50b70deb90b92b370

See more details on using hashes here.

File details

Details for the file tkcalendar-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tkcalendar-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2bce0cf6d17828454d3f3ed321baf771b7a06458ee8b7b7f050ec37e8bd49da2
MD5 cf53e78df64bc1f8153fd01b942be513
BLAKE2b-256 341e85a636a64eb580aac83b7458483fe693eec606776ca94960b51a50533a5c

See more details on using hashes here.

File details

Details for the file tkcalendar-1.1.2-py2.7.egg.

File metadata

File hashes

Hashes for tkcalendar-1.1.2-py2.7.egg
Algorithm Hash digest
SHA256 f68e55e501fd35ab4704ae780f39f2500ee292da56d5fbc840b42aedf275d6a0
MD5 fd6ca5611eb3c604f4c069d3b7ec2e44
BLAKE2b-256 5d7dc73b6ae0826ecdbb07838bc66233ed52322c43f5244d14454af9d15b2e3c

See more details on using hashes here.

File details

Details for the file tkcalendar-1.1.2-py2-none-any.whl.

File metadata

File hashes

Hashes for tkcalendar-1.1.2-py2-none-any.whl
Algorithm Hash digest
SHA256 ba29afac6a318d5884c3c99531be528eaf072c3d66ea943f4e9d7752ae72a8b7
MD5 1ceae7576a55d1159e615fe1ad709e2c
BLAKE2b-256 b9d10dc4521898327d6ff17e21140b78bb3e5bb26ea034f4ea6f465cd0afdb72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page