Tkcalendar python 3 документация

Documentation¶

cursor : str cursor to display when the pointer is in the widget font : str such as “Arial 20 bold” or a Tkinter Font instance font of the calendar borderwidth : int width of the border around the calendar state : str “normal” or “disabled” (unresponsive widget)

Widget-specific options¶

year : int intinitially displayed year, default is current year. month : int initially displayed month, default is current month. day : int initially selected day, if month or year is given but not day, no initial selection, otherwise, default is today. firstweekday : “monday” or “sunday” first day of the week showweeknumbers : boolean (default is True) whether to display week numbers. locale : str locale to use, e.g. ‘en_US’ selectmode : “none” or “day” (default) whether the user can change the selected day with a mouse click. textvariable : StringVar connect the currently selected date to the variable.

Style options¶

background : background color of calendar border and month/year name foreground : foreground color of month/year name bordercolor : day border color headersbackground : background color of day names and week numbers headersforeground : foreground color of day names and week numbers selectbackground : background color of selected day selectforeground : foreground color of selected day disabledselectbackground : background color of selected day in disabled state disabledselectforeground : foreground color of selected day in disabled state normalbackground : background color of normal week days normalforeground : foreground color of normal week days weekendbackground : background color of week-end days weekendforeground : foreground color of week-end days othermonthforeground : foreground color of normal week days belonging to the previous/next month othermonthbackground : background color of normal week days belonging to the previous/next month othermonthweforeground : foreground color of week-end days belonging to the previous/next month othermonthwebackground : background color of week-end days belonging to the previous/next month disableddaybackground : background color of days in disabled state disableddayforeground : foreground color of days in disabled state

Tooltip options (for calevents)¶

tooltipforeground : tooltip text color tooltipbackground : tooltip background color tooltipalpha : float tooltip opacity between 0 and 1 tooltipdelay : int delay in ms before displaying the tooltip

Источник

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. Events can be displayed in the Calendar with custom colors and a tooltip displays the event list for a given day. tkcalendar is compatible with both Python 2 and Python 3. It supports many locale settings (e.g. ‘fr_FR’, ‘en_US’, ..) and the colors are customizable.

License¶

tkcalendar — Calendar and DateEntry widgets for Tkinter

Copyright (C) 2017-2018 Juliette Monsel with contributions from:

tkcalendar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

tkcalendar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Читайте также:  background-attachment

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

© Copyright 2018, Juliette Monsel Revision 0c6aa7cb .

Versions latest stable v1.6.1 v1.6.0 v1.5.1 v1.5.0 v1.4.0 v1.3.1 v1.3.0 Downloads pdf html epub On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.

Источник

Calendar¶

cursor : str cursor to display when the pointer is in the widget font : str or Tkinter Font font of the calendar borderwidth : int width of the border around the calendar state : str “normal” or “disabled” (unresponsive widget)

Widget-specific Options

year : int intinitially displayed year, default is current year. month : int initially displayed month, default is current month. day : int initially selected day, if month or year is given but not day, no initial selection, otherwise, default is today. firstweekday : str first day of the week: “monday” or “sunday” weekenddays : list 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). mindate : datetime.date or datetime.datetime (default is None) minimum allowed date maxdate : datetime.date or datetime.datetime (default is None) maximum allowed date showweeknumbers : bool whether to display week numbers (default is True). showothermonthdays : bool whether to display the last days of the previous month and the first of the next month (default is True). locale : str locale to use, e.g. ‘en_US’ date_pattern : str

date pattern used to format the date as a string. The default pattern used is babel ’s short date format in the Calendar ’s locale.

A valid pattern is a combination of ‘d’, ‘m’ and ‘y’ separated by non letter characters to indicate how and in which order the year, month and day should be displayed.

d ‘d’ for the day of month number without padding, ‘dd’ for a two-digit day
m ‘m’ for the month number without padding, ‘mm’ for a two-digit month
y ‘yy’ for the two last digits of the year, any other number of ‘y’s for the full year with an extra padding of zero if it has less digits than the number of ‘y’s.

Examples for datetime.date(2019, 7, 1)

Style Options

background : str background color of calendar border and month/year name foreground : str foreground color of month/year name disabledbackground : str background color of calendar border and month/year name in disabled state disabledforeground : str foreground color of month/year name in disabled state bordercolor : str day border color headersbackground : str background color of day names and week numbers headersforeground : str foreground color of day names and week numbers selectbackground : str background color of selected day selectforeground : str foreground color of selected day disabledselectbackground : str background color of selected day in disabled state disabledselectforeground : str foreground color of selected day in disabled state normalbackground : str background color of normal week days normalforeground : str foreground color of normal week days weekendbackground : str background color of week-end days weekendforeground : str foreground color of week-end days othermonthforeground : str foreground color of normal week days belonging to the previous/next month othermonthbackground : str background color of normal week days belonging to the previous/next month othermonthweforeground : str foreground color of week-end days belonging to the previous/next month othermonthwebackground : str background color of week-end days belonging to the previous/next month disableddaybackground : str background color of days in disabled state disableddayforeground : str foreground color of days in disabled state

Читайте также:  Http do1 samgups ru dpo login index php

Tooltip Options (for calevents)

tooltipforeground : str tooltip text color tooltipbackground : str tooltip background color tooltipalpha : float tooltip opacity between 0 and 1 tooltipdelay : int delay in ms before displaying the tooltip calevent_cget ( ev_id, option ) [source] ¶

Return value of given option for the event ev_id.

Configure the event ev_id.

Keyword options: date, text, tags (see calevent_create options).

Add new event in calendar and return event id.

date : datetime.date or datetime.datetime event date text : str text to put in the tooltip associated to date. tags : list list of tags to apply to the event. The last tag determines the way the event is displayed. If there are several events on the same day, the lowest one (on the tooltip list) which has tags determines the colors of the day.

Lower event ev_id in tooltip event list.

The day’s colors are determined by the last tag of the lowest event which has tags.

Raise event ev_id in tooltip event list.

The day’s colors are determined by the last tag of the lowest event which has tags.

Remove events from calendar.

Arguments: event ids to remove or ‘all’ to remove them all.

Keyword arguments: tag, date.

They are taken into account only if no id is given. Remove all events with given tag on given date. If only date is given, remove all events on date and if only tag is given, remove all events with tag.

Configure resources of a widget.

The values for resources are specified as keyword arguments. To get an overview about the allowed keyword arguments call the method keys() .

Convert date (datetime.date) to a string in the locale.

Return event ids of events with given tag and on given date.

If only date is given, return event ids of all events on date. If only tag is given, return event ids of all events with tag. If both options are None, return all event ids.

Return selected date as string.

Return the currently displayed month in the form of a (month, year) tuple.

Return a list of all resource names of this widget.

Display the month in which date is.

Читайте также:  Как поймать льва в пустыне?

Return currently selected date (datetime.date instance).

Always return None if selectmode == “none”.

Set the selection to date.

date : datetime.date, datetime.datetime or str date to be made visible. If given as a string, it should be in the format corresponding to the calendar locale.

Do nothing if selectmode == “none”.

Return the value of the tag’s option.

Keyword options: foreground, background (of the day in the calendar)

Delete tag properties and remove tag from all events.

Return tuple of existing tags.

Virtual Events¶

  • A > event is generated each time the user selects a day with the mouse.
  • A > event is generated each time the user changes the displayed month.

Calendar Events¶

Special events (e.g. birthdays, ..) can be managed using the calevent_..() methods. The way they are displayed in the calendar is determined with tags. An id is attributed to each event upon creation and can be used to edit the event (ev_id argument).

© Copyright 2018, Juliette Monsel Revision 0c6aa7cb .

Versions latest stable v1.6.1 v1.6.0 v1.5.1 v1.5.0 v1.4.0 v1.3.1 v1.3.0 Downloads pdf html epub On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.

Источник

HowTos¶

All styling is done using options, see the documentation .

DateEntry inherits from ttk.Entry therefore the styling is done using a ttk style:

try: import tkinter as tk from tkinter import ttk except ImportError: import Tkinter as tk import ttk from tkcalendar import DateEntry style = ttk.Style() # style.theme_use('clam') # -> uncomment this line if the styling does not work style.configure('my.DateEntry', fieldbackground='light green', background='dark green', foreground='dark blue', arrowcolor='white') dateentry = DateEntry(style='my.DateEntry') dateentry.pack() tk.mainloop() 

If the style of the DateEntry does not change, then it might be because of the used ttk theme. Changing the theme with style.theme_use(‘clam’) should solve the issue.

PyInstaller¶

When bundling an application with PyInstaller, there is an issue (#32) with the detection of the babel dependency of tkcalendar. This can be fixed by using the —hidden-import option:

$ pyinstaller --hidden-import babel.numbers myscript.py

or by editing the .spec file:

hiddenimports=["babel.numbers"] 

Custom date formatting¶

When using the “en_US” locale, the default date formatting in the DateEntry , or when getting the selected date from the Calendar as a string is M/d/yy , i.e. July 4, 2019 will give “7/4/19”. If you want to get “07/04/2019” instead, you can pass “MM/dd/yyyy” to the date_pattern option of the Calendar or DateEntry .

try: import tkinter as tk from tkinter import ttk except ImportError: import Tkinter as tk import ttk from tkcalendar import DateEntry DateEntry(locale='en_US').pack() DateEntry(locale='en_US', date_pattern='MM/dd/yyyy').pack() tk.mainloop() 

© Copyright 2018, Juliette Monsel Revision 0c6aa7cb .

Versions latest stable v1.6.1 v1.6.0 v1.5.1 v1.5.0 v1.4.0 v1.3.1 v1.3.0 Downloads pdf html epub On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.

Источник

Оцените статью