How to use the param.Dict function in param

To help you get started, we’ve selected a few param examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holoviz / panel / panel / widgets / input.py View on Github external
Saves the uploaded FileInput data to a file or BytesIO object.

        Arguments
        ---------
        filename (str): File path or file-like object
        """
        if isinstance(filename, string_types):
            with open(filename, 'wb') as f:
                f.write(self.value)
        else:
            filename.write(self.value)


class StaticText(Widget):

    style = param.Dict(default=None, doc="""
        Dictionary of CSS property:value pairs to apply to this Div.""")

    value = param.Parameter(default=None)

    _format = '<b>{title}</b>: {value}'

    _rename = {'name': None, 'value': 'text'}

    _target_transforms = {'value': 'target.text.split(": ")[0]+": "+value'}

    _source_transforms = {'value': 'value.split(": ")[1]'}

    _widget_type = _BkDiv

    def _process_param_change(self, msg):
        msg = super(StaticText, self)._process_property_change(msg)
github holoviz / holoviews / holoviews / plotting / mpl / tabular.py View on Github external
numeric data types.""")

    max_value_len = param.Integer(default=20, doc="""
        The maximum allowable string length of a value shown in any
        table cell. Any strings longer than this length will be
        truncated.""")

    max_font_size = param.Integer(default=12, doc="""
        The largest allowable font size for the text in each table
        cell.""")

    max_rows = param.Integer(default=15, doc="""
        The maximum number of Table rows before the table is
        summarized.""")

    font_types = param.Dict(default={'heading': FontProperties(weight='bold',
                            family='DejaVu Sans')}, doc="""
        The font style used for heading labels used for emphasis.""")

    style_opts = ['alpha', 'sketch_params']

    # Disable axes handling for Table plots
    _has_axes = False

    def __init__(self, table, **params):
        super(TablePlot, self).__init__(table, **params)
        if not self.dynamic:
            self.cell_widths = self._format_table()
        else:
            self.cell_widths = None

github holoviz / holoviews / holoviews / plotting / mpl / plot.py View on Github external
The bounds of the overall figure as a 4-tuple of the form
        (left, bottom, right, top), defining the size of the border
        around the subplots.""")

    fig_inches = param.Parameter(default=4, doc="""
        The overall matplotlib figure size in inches.  May be set as
        an integer in which case it will be used to autocompute a
        size. Alternatively may be set with an explicit tuple or list,
        in which case it will be applied directly after being scaled
        by fig_size. If either the width or height is set to None,
        it will be computed automatically.""")

    fig_latex = param.Boolean(default=False, doc="""
        Whether to use LaTeX text in the overall figure.""")

    fig_rcparams = param.Dict(default={}, doc="""
        matplotlib rc parameters to apply to the overall figure.""")

    fig_size = param.Number(default=100., bounds=(1, None), doc="""
        Size relative to the supplied overall fig_inches in percent.""")

    initial_hooks = param.HookList(default=[], doc="""
        Optional list of hooks called before plotting the data onto
        the axis (now marked for deprecation). The hook is passed the
        plot object and the displayed object; other plotting handles
        can be accessed via plot.handles.""")

    finalize_hooks = param.HookList(default=[], doc="""
        Deprecated; use hooks options instead.""")

    hooks = param.HookList(default=[], doc="""
        Optional list of hooks called when finalizing a plot. The
github holoviz / panel / panel / pane / web_component.py View on Github external
The attributes and parameters are automatically synchronized

    If an attribute key has a parameter value of None then the attribute is still observed and changes
    are update in the html parameter. But it is not synchronized to a parameter.

    DO NOT CHANGE AFTER CONSTRUCTION OF THE OBJECT!

    Example
    ~~~~~~~

    `attributes_to_watch = {"checked": "checked", "value": None, "ballSize": "ball_size"}`
    """
    )
    # @philippjfr: Can we enforce that this is Dict[str, Optional[str]]?
    attributes_last_change = param.Dict(
        doc="""

    The key is the name of the attribute changed. The value is the new value of the attribute.

    Please note that the value is a string or None

    Examples
    ~~~~~~~~

    ```
    attributes_last_change = {"checked": ""}
    attributes_last_change = {"value": None}
    attributes_last_change = {"ballSize": "2"}
    ```
    """
    )
github pyviz-topics / EarthSim / earthsim / annotators.py View on Github external
polys = param.ClassSelector(class_=Path, precedence=-1, doc="""
         Polygon or Path element to annotate""")

    points = param.ClassSelector(class_=Points, precedence=-1, doc="""
         Point element to annotate""")

    num_points = param.Integer(default=None, doc="""
         Maximum number of points to allow drawing (unlimited by default).""")

    num_polys = param.Integer(default=None, doc="""
         Maximum number of polygons to allow drawing (unlimited by default).""")

    node_style = param.Dict(default={'fill_color': 'indianred', 'size': 6}, doc="""
         Styling to apply to the node vertices.""")

    feature_style = param.Dict(default={'fill_color': 'blue', 'size': 10}, doc="""
         Styling to apply to the feature vertices.""")

    height = param.Integer(default=500, doc="Height of the plot",
                           precedence=-1)

    width = param.Integer(default=900, doc="Width of the plot",
                          precedence=-1)

    def __init__(self, polys=None, points=None, crs=None, **params):
        super(GeoAnnotator, self).__init__(**params)
        plot_opts = dict(height=self.height, width=self.width)
        self.tiles = WMTS(self.tile_url, extents=self.extent,
                          crs=ccrs.PlateCarree()).opts(plot=plot_opts)
        polys = [] if polys is None else polys
        points = [] if points is None else points
        crs = ccrs.GOOGLE_MERCATOR if crs is None else crs
github holoviz / panel / panel / layout / grid.py View on Github external
old = self.objects
            objects = self._get_objects(model, old, doc, root, comm)
            children = self._get_children(objects, self.nrows, self.ncols)
            msg[self._rename['objects']] = children

        with hold(doc):
            msg = {k: v for k, v in msg.items() if k not in ('nrows', 'ncols')}
            super(Panel, self)._update_model(events, msg, root, model, doc, comm)
            ref = root.ref['id']
            if ref in state._views:
                state._views[ref][0]._preprocess(root)


class GridSpec(Panel):

    objects = param.Dict(default={}, doc="""
        The dictionary of child objects that make up the grid.""")

    mode = param.ObjectSelector(default='warn', objects=['warn', 'error', 'override'], doc="""
        Whether to warn, error or simply override on overlapping assignment.""")

    width = param.Integer(default=600)

    height = param.Integer(default=600)

    _bokeh_model = BkGridBox

    _source_transforms = {'objects': None, 'mode': None}

    _rename = {'objects': 'children', 'mode': None}

    def __init__(self, **params):
github pyviz-topics / imagen / dataviews / ndmapping.py View on Github external
support separate from the indexing and data storage methods helps make both
    classes easier to understand.
    """

    dimension_labels = param.List(default=[None], constant=True, doc="""
        The dimension_labels parameter accepts a list of the features
        along which the data will indexed.""")

    data_type = param.Parameter(default=None, constant=True)

    dim_info = param.Dict(default={}, constant=True, doc="""
        Information associated with the dimension labels, supplied as a
        dictionary. The key 'type' specifies the key type, other potentially
        useful keys include units and cyclic_range for periodic dimensions.""")

    metadata = param.Dict(default=AttrDict(), doc="""
        Additional labels to be associated with the Dataview.""")

    sorted = param.Boolean(default=True, doc="""
        Determines whether to keep internal data structure sorted, using
        all dimensions indices to sort on. Important if data is not added in
        a consistently increasing order but the order matters for plotting
        or other purposes.""")

    _deep_indexable = True

    _check_key_type = True

    def __init__(self, initial_items=None, **kwargs):
        self._data = map_type()

        kwargs, metadata = self.write_metadata(kwargs)
github holoviz / panel / panel / config.py View on Github external
pn.config.embed = True

        pn.extension(embed=True)

        os.environ['PANEL_EMBED'] = 'True'
    """

    apply_signatures = param.Boolean(default=True, doc="""
        Whether to set custom Signature which allows tab-completion
        in some IDEs and environments.""")

    css_files = param.List(default=_CSS_FILES, doc="""
        External CSS files to load.""")

    js_files = param.Dict(default={}, doc="""
        External JS files to load. Dictionary should map from exported
        name to the URL of the JS file.""")

    raw_css = param.List(default=[], doc="""
        List of raw CSS strings to add to load.""")

    safe_embed = param.Boolean(default=False, doc="""
        Ensure all bokeh property changes trigger events which are
        embedded. Useful when only partial updates are made in an
        app, e.g. when working with HoloViews.""")

    sizing_mode = param.ObjectSelector(default=None, objects=[
        'fixed', 'stretch_width', 'stretch_height', 'stretch_both',
        'scale_width', 'scale_height', 'scale_both', None], doc="""
        Specify the default sizing mode behavior of panels.""")
github holoviz / panel / panel / pane / deckgl.py View on Github external
DeckGL panes allow rendering Deck.Gl/ PyDeck plots in Panel.
    """

    mapbox_api_key = param.String(default=None, doc="""
        The MapBox API key if not supplied by a PyDeck object.""")

    tooltips = param.ClassSelector(default=True, class_=(bool, dict), doc="""
        Whether to enable tooltips""")

    click_state = param.Dict(default={}, doc="""
        Contains the last click event on the DeckGL plot.""")

    hover_state = param.Dict(default={}, doc="""
        The current hover state of the DeckGL plot.""")

    view_state = param.Dict(default={}, doc="""
        The current view state of the DeckGL plot.""")

    _rename = {
        'click_state': 'clickState', 'hover_state': 'hoverState',
        'view_state': 'viewState', 'tooltips': 'tooltip'
    }

    _updates = True

    priority = None

    @classmethod
    def applies(cls, obj):
        if (hasattr(obj, "to_json") and hasattr(obj, "mapbox_key")
            and hasattr(obj, "deck_widget")):
            return 0.8
github holoviz / panel / panel / param.py View on Github external
to widget class.""")

    priority = 0.1

    _unpack = True

    _mapping = {
        param.Action:            Button,
        param.Boolean:           Checkbox,
        param.CalendarDate:      DatePicker,
        param.Color:             ColorPicker,
        param.Date:              DatetimeInput,
        param.DateRange:         DateRangeSlider,
        param.CalendarDateRange: DateRangeSlider,
        param.DataFrame:         DataFrame,
        param.Dict:              LiteralInputTyped,
        param.FileSelector:      SingleFileSelector,
        param.Filename:          TextInput,
        param.Foldername:        TextInput,
        param.Integer:           IntSlider,
        param.List:              LiteralInputTyped,
        param.MultiFileSelector: FileSelector,
        param.ListSelector:      MultiSelect,
        param.Number:            FloatSlider,
        param.ObjectSelector:    Select,
        param.Parameter:         LiteralInputTyped,
        param.Range:             RangeSlider,
        param.Selector:          Select,
        param.String:            TextInput,
    }

    _rerender_params = []