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