How to use the param.String 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 filecoin-project / lotus / testplans / composer / app / composition.py View on Github external
def str_param(pdef):
    return param.String(
        default=pdef.get('default', ''),
        doc=pdef.get('desc', ''),
    )
github holoviz / panel / panel / widgets / misc.py View on Github external
callback = param.Callable(default=None, doc="""
        A callable that returns the file path or file-like object.""")

    data = param.String(default=None, doc="""
        The data being transferred.""")

    embed = param.Boolean(default=False, doc="""
        Whether to embed the file on initialization.""")

    file = param.Parameter(default=None, doc="""
        The file, file-like object or file contents to transfer.  If
        the file is not pointing to a file on disk a filename must
        also be provided.""")

    filename = param.String(default=None, doc="""
        A filename which will also be the default name when downloading
        the file.""")

    label = param.String(default="Download file", doc="""
        The label of the download button""")

    _clicks = param.Integer(default=0)

    _transfers = param.Integer(default=0)

    _mime_types = {
        'application': {
            'pdf': 'pdf', 'zip': 'zip'
        },
        'audio': {
            'mp3': 'mp3', 'ogg': 'ogg', 'wav': 'wav', 'webm': 'webm'
github holoviz / panel / panel / io / location.py View on Github external
"""
    The Location component can be made available in a server context
    to provide read and write access to the URL components in the
    browser.
    """

    href = param.String(readonly=True, doc="""
        The full url, e.g. 'https://localhost:80?color=blue#interact'""")

    hostname = param.String(readonly=True, doc="""
        hostname in window.location e.g. 'panel.holoviz.org'""")

    pathname = param.String(regex=r"^$|[\/].*$", doc="""
        pathname in window.location e.g. '/user_guide/Interact.html'""")

    protocol = param.String(readonly=True, doc="""
        protocol in window.location e.g. 'http:' or 'https:'""")

    port = param.String(readonly=True, doc="""
        port in window.location e.g. '80'""")

    search = param.String(regex=r"^$|\?", doc="""
        search in window.location e.g. '?color=blue'""")

    hash = param.String(regex=r"^$|#", doc="""
        hash in window.location e.g. '#interact'""")

    reload = param.Boolean(default=False, doc="""
        Reload the page when the location is updated. For multipage
        apps this should be set to True, For single page apps this
        should be set to False""")
github holoviz / panel / panel / io / location.py View on Github external
browser.
    """

    href = param.String(readonly=True, doc="""
        The full url, e.g. 'https://localhost:80?color=blue#interact'""")

    hostname = param.String(readonly=True, doc="""
        hostname in window.location e.g. 'panel.holoviz.org'""")

    pathname = param.String(regex=r"^$|[\/].*$", doc="""
        pathname in window.location e.g. '/user_guide/Interact.html'""")

    protocol = param.String(readonly=True, doc="""
        protocol in window.location e.g. 'http:' or 'https:'""")

    port = param.String(readonly=True, doc="""
        port in window.location e.g. '80'""")

    search = param.String(regex=r"^$|\?", doc="""
        search in window.location e.g. '?color=blue'""")

    hash = param.String(regex=r"^$|#", doc="""
        hash in window.location e.g. '#interact'""")

    reload = param.Boolean(default=False, doc="""
        Reload the page when the location is updated. For multipage
        apps this should be set to True, For single page apps this
        should be set to False""")

    # Mapping from parameter name to bokeh model property name
    _rename = {"name": None}
github holoviz / panel / panel / themes / theme_builder / theme.py View on Github external
According to Material Design Palette.

Source: https://github.com/angular/components/blob/master/src/material/core/theming/_palette.scss
"""
import param

from . import color
from .color_palette import GREY


class ThemeForeground(param.Parameterized):
    """Material Design Theme Foreground settings"""
    base = param.String(color.BLACK)
    divider = param.String(color.DARK_DIVIDERS)
    dividers = param.String(color.DARK_DIVIDERS)
    disabled = param.String(color.DARK_DISABLED_TEXT)
    disabled_button = param.String("rgba(0,0,0, 0.26)")
    disabled_text = param.String(color.DARK_DISABLED_TEXT)
    elevation = param.String(color.BLACK)
    hint_text = param.String(color.DARK_DISABLED_TEXT)
    primary_text = param.String(color.DARK_PRIMARY_TEXT)
    secondary_text = param.String(color.DARK_SECONDARY_TEXT)
    icon = param.String("rgba(0,0,0 , 0.54)")
    icons = param.String("rgba(0,0,0 , 0.54)")
    text = param.String("rgba(0,0,0 , 0.87)")
    slider_min = param.String("rgba(0,0,0 , 0.87)")
    slider_off = param.String("rgba(0,0,0 , 0.26)")
    slider_off_active = param.String("rgba(0,0,0 , 0.38)")

    def __eq__(self, other):
        return self.name == other.name
github holoviz / holoviews / holoviews / operation / rgb.py View on Github external
return RGB(matplotlib.cm.get_cmap(self.p.cmap)(matrix.data),
                   bounds = matrix.bounds,
                   label = matrix.label,
                   group=self.p.group)



class alpha_overlay(ElementOperation):
    """
    Accepts an overlay of a Image defined with a cmap and converts it
    to an RGB element whereby the alpha channel of the result is
    obtained from the second layer of the overlay.
    """

    group = param.String(default='AlphaOverlay', doc="""
        The group string for the output (an RGB element).""")

    cmap = param.String(default='jet', doc="""
        The name of matplotlib color map to apply.""")

    def _process(self, overlay, key=None):
        R,G,B,_ = split_raster(colormap(overlay[0], cmap=self.p.cmap))
        return RGB(R*G*B*overlay[1],
                   bounds=self.get_overlay_extents(overlay),
                   label=self.get_overlay_label(overlay),
                   group=self.p.group)


class colorizeHSV(ElementOperation):
    """
    Given an Overlay consisting of two Image elements, colorize the
github holoviz / datashader / datashader / layout.py View on Github external
__abstract = True

    seed = param.Integer(default=None, bounds=(0, 2**32-1), doc="""
        Random seed used to initialize the pseudo-random number
        generator.""")

    x = param.String(default='x', doc="""
        Column name for each node's x coordinate.""")

    y = param.String(default='y', doc="""
        Column name for each node's y coordinate.""")

    source = param.String(default='source', doc="""
        Column name for each edge's source.""")

    target = param.String(default='target', doc="""
        Column name for each edge's target.""")

    weight = param.String(default=None, allow_None=True, doc="""
        Column name for each edge weight. If None, weights are ignored.""")

    id = param.String(default=None, allow_None=True, doc="""
        Column name for a unique identifier for the node.  If None, the
        dataframe index is used.""")

    def __call__(self, nodes, edges, **params):
        """
        This method takes two dataframes representing a graph's nodes
        and edges respectively. For the nodes dataframe, the only
        column accessed is the specified `id` value (or the index if
        no 'id'). For the edges dataframe, the columns are `id`,
        `source`, `target`, and (optionally) `weight`.
github ioam / lancet / lancet / launch.py View on Github external
expansions = param.Dict(default={}, constant=True, doc='''
        Allows extension of the specification that supports functions
        that expand to valid argument values.  If a function is used,
        it must have the signature (spec, info, tid). A typical usage
        for a function value is to build a valid output filename given
        the context.

        Three such subclasses are provided:
        'RootDirectory', 'LongFilename' and 'Expand'.''')

    posargs = param.List(default=[], constant=True, doc='''
       The list of positional argument keys. Positional arguments are
       always supplied at the end of a command in the order given.''')

    short_prefix = param.String(default='-',  constant=True, doc='''
       Although the single dash is a GNU coding convention, the
       argument prefix may depend on the applications and/or platform.''')

    long_prefix = param.String(default='--',  constant=True, doc='''
       Although the double dash is a GNU coding convention, some
       applications use single dashes for long options.''')

    def __init__(self, executable, **params):
        super(ShellCommand,self).__init__(executable = executable,
                                          do_format=False,
                                          **params)
        self.pprint_args(['executable','posargs'],['long_prefix'])

    def __call__(self, spec, tid=None, info={}):
        # Function expansions are called here.
        expanded = type(spec)()
github pyviz-dev / nbsite / examples / sites / holoviews / holoviews / element / annotation.py View on Github external
text = param.String(default='', doc="Text associated with the arrow.")

    direction = param.ObjectSelector(default='<',
                                     objects=['<', '^', '>', 'v'], doc="""
        The cardinal direction in which the arrow is pointing. Accepted
        arrow directions are '<', '^', '>' and 'v'.""")

    arrowstyle = param.ObjectSelector(default='->',
                                      objects=['-', '->', '-[', '-|>', '<->', '<|-|>'],
                                      doc="""
        The arrowstyle used to draw the arrow. Accepted arrow styles are
        '-', '->', '-[', '-|>', '<->' and '<|-|>'""")

    points = param.Number(default=40, doc="Font size of arrow text (if any).")

    group = param.String(default='Arrow', constant=True)

    __pos_params = ['x', 'y', 'text', 'direction', 'points', 'arrowstyle']

    def __init__(self, x, y, text='', direction='<',
                 points=40, arrowstyle='->', **params):

        info = (x, y, text, direction, points, arrowstyle)
        super(Arrow, self).__init__(info, x=x, y=y,
                                    text=text, direction=direction,
                                    points=points, arrowstyle=arrowstyle,
                                    **params)

    def __setstate__(self, d):
        """
        Add compatibility for unpickling old Arrow types with different
        .data format.
github pyviz-dev / nbsite / examples / sites / holoviews / holoviews / streams.py View on Github external
def define(cls, name, **kwargs):
        """
        Utility to quickly and easily declare Stream classes. Designed
        for interactive use such as notebooks and shouldn't replace
        parameterized class definitions in source code that is imported.

        Takes a stream class name and a set of keywords where each
        keyword becomes a parameter. If the value is already a
        parameter, it is simply used otherwise the appropriate parameter
        type is inferred and declared, using the value as the default.

        Supported types: bool, int, float, str, dict, tuple and list
        """
        params = {'name':param.String(default=name)}
        for k,v in kwargs.items():
            kws = dict(default=v, constant=True)
            if isinstance(v, param.Parameter):
                params[k] = v
            elif isinstance(v, bool):
                params[k] = param.Boolean(**kws)
            elif isinstance(v, int):
                params[k] = param.Integer(**kws)
            elif isinstance(v, float):
                params[k] = param.Number(**kws)
            elif isinstance(v,str):
                params[k] = param.String(**kws)
            elif isinstance(v,dict):
                params[k] = param.Dict(**kws)
            elif isinstance(v, tuple):
                params[k] = param.Tuple(**kws)