コード例 #1
0
ファイル: widget_template.py プロジェクト: deathbeds/wxyz
class Template(Fn, JinjaBase):
    """Transforms text source into text output with a given context"""

    _model_name = T.Unicode("TemplateModel").tag(sync=True)

    context = T.Union([T.Dict(), T.Instance(W.Widget)],
                      allow_none=True).tag(sync=True, **W.widget_serialization)

    _observed_traits = ["source", "context"]

    @T.observe("context")
    def _context_changed(self, *_):
        """handle connecting to widgets"""
        if self.context and self.context.observe:
            self.context.observe(self.the_observer)

    def the_function(self, source, context):
        """render a source given a context"""
        return jinja2.Template(source).render(context)
コード例 #2
0
ファイル: widget_jsonld.py プロジェクト: deathbeds/wxyz
class Normalize(Fn, JSONLDBase):
    """Normalize a JSON document"""

    _model_name = T.Unicode("NormalizeModel").tag(sync=True)

    _observed_traits = ["source", "frame", "expand_context"]

    source = T.Dict(allow_none=True).tag(sync=True)
    expand_context = T.Dict(allow_none=True).tag(sync=True)
    format = T.Unicode(default_value="application/n-quads",
                       allow_none=True).tag(sync=True)

    value = T.Union([T.Dict(allow_none=True),
                     T.Unicode(allow_none=True)]).tag(sync=True)

    _observed_traits = ["source", "format", "expand_context"]

    def the_function(self, source, format, expand_context):
        """actually normalize"""
        return jsonld.normalize(
            source, dict(expandContext=expand_context, format=format))
コード例 #3
0
class GridStyle(W.Widget):
    """JSON-compatible Lumino `DataGrid` styles."""

    # pylint: disable=C0301
    _model_name = T.Unicode("GridStyleModel").tag(sync=True)
    _model_module = T.Unicode(module_name).tag(sync=True)
    _model_module_version = T.Unicode(module_version).tag(sync=True)

    # the part between these comments will be rewritten
    # BEGIN SCHEMAGEN:TRAITS IDataGridStyles @b911858621aef508319fec6b6d1cbe8afeeb8ffafe0646c0083d9491e3277e78
    backgroundColor = T.Unicode(
        help="""The background color for the body cells.

This color is layered on top of the `voidColor`.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    columnBackgroundColor = T.Union(
        [T.Tuple(), T.Enum([None])], allow_none=True, default_value=None
    ).tag(sync=True)
    cursorBorderColor = T.Unicode(
        help="""The border color for the cursor.""", allow_none=True, default_value=None
    ).tag(sync=True)
    cursorFillColor = T.Unicode(
        help="""The fill color for the cursor.""", allow_none=True, default_value=None
    ).tag(sync=True)
    gridLineColor = T.Unicode(
        help="""The color for the grid lines of the body cells.

The grid lines are draw on top of the cell contents.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerBackgroundColor = T.Unicode(
        help="""The background color for the header cells.

This color is layered on top of the `voidColor`.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerGridLineColor = T.Unicode(
        help="""The color for the grid lines of the header cells.

The grid lines are draw on top of the cell contents.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerHorizontalGridLineColor = T.Unicode(
        help="""The color for the horizontal grid lines of the header cells.

This overrides the `headerGridLineColor` option.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerSelectionBorderColor = T.Unicode(
        help="""The border color for a header selection.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerSelectionFillColor = T.Unicode(
        help="""The fill color for a header selection.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    headerVerticalGridLineColor = T.Unicode(
        help="""The color for the vertical grid lines of the header cells.

This overrides the `headerGridLineColor` option.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    horizontalGridLineColor = T.Unicode(
        help="""The color for the horizontal grid lines of the body cells.

This overrides the `gridLineColor` option.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    rowBackgroundColor = T.Union(
        [T.Tuple(), T.Enum([None])],
        help="""Realized as a functor, a single value will affect all rows, while any other value will be return modulo the position.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    scrollShadow = T.Dict(
        help="""The drop shadow effect when the grid is scrolled.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    selectionBorderColor = T.Unicode(
        help="""The border color for a selection.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    selectionFillColor = T.Unicode(
        help="""The fill color for a selection.""", allow_none=True, default_value=None
    ).tag(sync=True)
    verticalGridLineColor = T.Unicode(
        help="""The color for the vertical grid lines of the body cells.

This overrides the `gridLineColor` option.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)
    voidColor = T.Unicode(
        help="""The void color for the data grid.

This is the base fill color for the entire data grid.""",
        allow_none=True,
        default_value=None,
    ).tag(sync=True)