1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
from traits.api import Bool, List, Str
from .date_editor import DateEditor
class CellFormat(object):
""" Encapsulates some common visual attributes to set on the cells of a
calendar widget. All attributes default to None, which means that they
will not override the existing values of the calendar widget.
"""
italics = None
bold = None
underline = None
# The color attributes should be strings representing color names,
# from the list:
# red, green, blue, cyan, magenta, yellow, gray, white,
# darkRed, darkGreen, darkBlue, darkCyan, darkmagenta, darkYellow, darkGray,
# black, lightGray
#
# Alternatively, they can be a tuple of (R,G,B) values from 0-255.
bgcolor = None
fgcolor = None
def __init__(self, **args):
for key,val in args.items():
setattr(self, key, val)
class ToolkitEditorFactory(DateEditor):
""" A DateEditor that can show sets of dates in different styles.
"""
# The name of a dictionary on the object that maps names to groups
# (list/tuples) of datetime.date objects. Each of these groups can be
# styled using the **styles** dict.
dates_trait = Str()
# The name of a dictionary on the object that maps names of styles to
# CellFormat objects. The names used must match the names used in the
# **dates** dict.
styles_trait = Str()
# Allow selection of arbitrary dates in the past.
allow_past = Bool(True)
# Allow selection of arbitrary dates in the future.
allow_future = Bool(True)
# A list of strings that will be offered as an alternative to specifying
# an absolute date, and instead specify a relative date.
relative_dates = List()
StyledDateEditor = ToolkitEditorFactory
|