~ubuntu-branches/ubuntu/utopic/python-traitsui/utopic

« back to all changes in this revision

Viewing changes to traitsui/editors/styled_date_editor.py

  • Committer: Package Import Robot
  • Author(s): Varun Hiremath
  • Date: 2012-04-23 16:05:43 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20120423160543-bgafgw04y68arfjn
Tags: 4.1.0-1
* New upstream release
* Bump Standards-Version to 3.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from traits.api import Bool, List, Str
 
3
from .date_editor import DateEditor
 
4
 
 
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.
 
9
    """
 
10
 
 
11
    italics = None
 
12
    bold = None
 
13
    underline = None
 
14
 
 
15
    # The color attributes should be strings representing color names,
 
16
    # from the list:
 
17
    #   red, green, blue, cyan, magenta, yellow, gray, white,
 
18
    #   darkRed, darkGreen, darkBlue, darkCyan, darkmagenta, darkYellow, darkGray,
 
19
    #   black, lightGray
 
20
    #
 
21
    # Alternatively, they can be a tuple of (R,G,B) values from 0-255.
 
22
    bgcolor = None
 
23
    fgcolor = None
 
24
 
 
25
    def __init__(self, **args):
 
26
        for key,val in args.items():
 
27
            setattr(self, key, val)
 
28
 
 
29
 
 
30
class ToolkitEditorFactory(DateEditor):
 
31
    """ A DateEditor that can show sets of dates in different styles.
 
32
    """
 
33
 
 
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.
 
37
    dates_trait = Str()
 
38
 
 
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
 
41
    # **dates** dict.
 
42
    styles_trait = Str()
 
43
 
 
44
    # Allow selection of arbitrary dates in the past.
 
45
    allow_past = Bool(True)
 
46
 
 
47
    # Allow selection of arbitrary dates in the future.
 
48
    allow_future = Bool(True)
 
49
 
 
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()
 
53
 
 
54
StyledDateEditor = ToolkitEditorFactory