Python源码示例:panel.Column()

示例1
def player_with_name_and_value(source):
    """
    source: pn.widgets.DiscretePlayer()
    target: consists of source player's name, value and player itself

    With pn.widgets.DiscretePlayer, we don't get name and
    value updates in textual form. This method is useful
    in case we want name and continuous value update.
    """
    mark = pn.pane.Markdown(f'{source.value}')

    def callback(*events):
        for event in events:
            if event.name == 'value':
                mark.object = str(event.new)

    source.param.watch(callback, ['value'], onlychanged=False)
    target = pn.Column(pn.Row(source.name, mark), source)
    return target 
示例2
def __init__(self, cat, **kwargs):
            self.cat = cat
            super().__init__(cats=[self.cat], **kwargs)
            self.panel = pn.Column(
                pn.Row(
                    pn.panel(ICONS['logo']),
                    pn.Row(
                        pn.Column(
                            self.select.panel,
                            self.control_panel,
                            margin=0
                        ),
                        self.description.panel,
                        margin=0
                    ),
                ),
                self.plot.panel
            ) 
示例3
def __init__(self, sources=None, cats=None, done_callback=None, **kwargs):
        """Set sources or cats to initialize the class - sources trumps cats.

        The order of the calls in this method matters and is different
        from the order in other panel init methods because the top level
        gui class needs to be able to watch these widgets.
        """
        self.panel = pn.Column(name='Select Data Source', margin=0)
        self.widget = pn.widgets.MultiSelect(size=9, min_width=200, width_policy='min')
        self.done_callback = done_callback
        super().__init__(**kwargs)

        if sources is not None:
            self.items = sources
        elif cats is not None:
            self.cats = cats 
示例4
def setup(self):
        self._setup_watchers()
        self.children = [
            pn.Column(
                pn.Row(
                    pn.Column(
                        self.select.panel,
                        self.control_panel,
                        margin=0,
                    ),
                    self.description.panel,
                    margin=0,
                ),
                self.plot.panel,
                margin=0,
                width_policy='max'
            )
        ] 
示例5
def __init__(self, cats=None):
        self.source = SourceGUI()
        self.cat = CatGUI(cats=cats, done_callback=self.done_callback)
        self.panel = pn.Column(
            pn.Row(
                pn.panel(ICONS['logo']),
                pn.Column(
                    self.cat.select.panel,
                    self.cat.control_panel,
                    margin=0, width_policy='max'),
                pn.Column(
                    self.source.select.panel,
                    self.source.control_panel,
                    margin=0, width_policy='max'
                ),
                self.source.description.panel,
                margin=0, width_policy='max'
            ),
            pn.Row(self.cat.search.panel, self.cat.add.panel,
                   self.source.plot.panel, width_policy='max'),
            width_policy='max'
        )
        super(GUI, self).__init__() 
示例6
def panel(self):
        map_view = self.annot.map_view().opts(height=600, width=600) * gvts.EsriImagery

        return pn.Row(pn.Column(map_view, pn.panel(self.param, parameters=['create'], show_name=False)),
                      pn.Column(self.annot.point_table,
                                pn.panel(self.param, parameters=['node_spacing'], show_name=False))) 
示例7
def panel(self):
        return pn.Column(self.view) 
示例8
def __init__(self, data):
        super().__init__()
        self.data = data
        self.name = 'Set Coords'
        self.coord_selector = pn.widgets.CrossSelector(
            value=list(self.data.coords),
            options=list(self.data.variables)
        )

        self.panel = pn.Column(
            pn.pane.Markdown(TEXT, margin=(0, 20)),
            self.coord_selector, name=self.name) 
示例9
def __init__(self, data):
        super().__init__()
        self.data = data

        dim_header = pn.pane.Markdown('### Plot Dimensions', margin=(0, 20, 0, 20))
        self.x = pn.widgets.Select(name='x', width=240, margin=(0, 20, 5, 20))
        self.y = pn.widgets.Select(name='y', width=240, margin=(0, 20, 20, 20))

        agg_header = pn.pane.Markdown('### Aggregations', margin=(0, 20, 0, 20))
        self.agg_selectors = pn.Column()
        self.agg_opts = ['select', 'animate', 'mean', 'max',
                         'min', 'median', 'std', 'count']
        self.series_col = pn.Column()
        self.are_var_coords = False

        self._register(self.x, 'x')
        self._register(self.y, 'y')

        self.connect('x', self.change_y)
        self.connect('y', self.change_dim_selectors)

        self.panel = pn.Column(
            pn.pane.Markdown(TEXT, margin=(0, 10)),
            pn.Row(
                pn.WidgetBox(dim_header, self.x, self.y,
                             background=(240, 240, 240)),
                pn.Spacer(),
                pn.WidgetBox(agg_header, self.agg_selectors,
                             background=(240, 240, 240))
            ),
            self.series_col,
            name='Axes') 
示例10
def kwargs(self):
        # Column(name='Axes')
        #     [0] Row
        #         [0] Column(background='rgb(175,175,175)')
        #             [0] Markdown(str)
        #             [1] Select(name='x', width=200)
        #             [2] Select(name='y', width=200)
        #         [1] Spacer()
        #         [2] Column(background='rgb(175,175,175)')
        #             [0] Markdown(str)
        #             [1] Column()
        #     [1] Column
        #         [0] Select()
        out = {p.name: p.value for p in self.panel[1][0][1:]}  # since panel[0][0][1] is Markdown
        selectors = {p.name: p.value for p in self.panel[1][2][1]}  # remaining_dims
        out.update(selectors)
        dims_to_select_animate = [dim for dim, agg in selectors.items() if agg in ['select', 'animate']]
        dims_to_agg = [dim for dim in selectors
                       if dim not in dims_to_select_animate]
        out.update({'dims_to_agg': dims_to_agg})
        out.update({'dims_to_select_animate': sorted(dims_to_select_animate)})
        out.update({'are_var_coords': self.are_var_coords})
        # remaining_dims = dims_to_agg + dims_to_select_animate
        out.update({'remaining_dims': self.remaining_dims})
        out.update({p.name: p.value for p in self.series_col})
        return out 
示例11
def __init__(self):
        super().__init__()
        self.frame_height = pn.widgets.IntSlider(name='frame_height', value=300, start=100,
                                                 end=1200)
        self.frame_width = pn.widgets.IntSlider(name='frame_width', value=450, start=100,
                                                end=1200)
        self.cmap = pn.widgets.Select(name='cmap', value='Inferno',
                                      options=list_cmaps())
        self.colorbar = pn.widgets.Checkbox(name='colorbar', value=True, width=150)
        # colormap_limits
        self.lower_limit = pn.widgets.TextInput(name='cmap lower limit',
                                                width=140)
        self.upper_limit = pn.widgets.TextInput(name='cmap upper limit',
                                                width=140)
        self.use_all_data = pn.widgets.Checkbox(name='compute min/max from all data', value=False)

        scaling_ops = ['linear', 'exp', 'log', 'reciprocal', 'square', 'sqrt']
        self.color_scale = pn.widgets.Select(name='color_scale',
                                             value='linear',
                                             options=scaling_ops)
        self.rasterize = pn.widgets.Checkbox(name='rasterize', value=True, width=150)

        self._register(self.use_all_data, 'clear_cmap_limits')
        self._register(self.color_scale, 'clear_cmap_limits')
        self.connect('clear_cmap_limits', self.setup)

        self.panel = pn.Column(
            pn.pane.Markdown(TEXT, margin=(0, 10)),
            pn.Row(self.frame_height, self.frame_width),
            pn.Row(self.cmap, self.color_scale),
            pn.Row(self.lower_limit, self.upper_limit),
            pn.Row(self.use_all_data, self.colorbar, self.rasterize),
            name='Style'
        ) 
示例12
def __init__(self, source=None, **kwargs):
            self.source = source
            super().__init__(sources=[self.source], **kwargs)
            self.panel = pn.Column(
                pn.Row(ICONS['logo'], pn.Column(*self.controls)),
                self.description.panel,
                self.plot.panel
            ) 
示例13
def __init__(self, filters=['yaml', 'yml'], done_callback=None,  **kwargs):
        self.filters = filters
        self.panel = pn.Column(name='Local', width_policy='max', margin=0)
        self.done_callback = done_callback
        self.fs = fsspec.filesystem("file")
        super().__init__(**kwargs) 
示例14
def __init__(self, done_callback=None, **kwargs):
        self.done_callback = done_callback
        self.panel = pn.Column(name='Add Catalog',
                               width_policy='max',
                               max_width=MAX_WIDTH,
                               margin=0)
        self.widget = pn.widgets.Button(name='Add Catalog',
                                        disabled=True,
                                        width_policy='min')
        self.fs = FileSelector(done_callback=partial(enable_widget, self.widget))
        self.url = URLSelector()
        super().__init__(**kwargs) 
示例15
def __init__(self, cats=None, done_callback=None, **kwargs):
        """Set cats to initialize the class.

        The order of the calls in this method matters and is different
        from the order in other panel init methods because the top level
        gui class needs to be able to watch these widgets.
        """
        self.panel = pn.Column(name='Select Catalog', margin=0)
        self.widget = pn.widgets.MultiSelect(size=9, min_width=200, width_policy='min')
        self.done_callback = done_callback
        super().__init__(**kwargs)

        self.items = cats if cats is not None else [intake.cat] 
示例16
def __init__(self, source=None, **kwargs):
        self.source = source
        self.panel = pn.Column(name='Description', width_policy='max',
                               margin=0, height=240, sizing_mode='stretch_width',
                               scroll=True)
        super().__init__(**kwargs) 
示例17
def __init__(self):
        self.panel = pn.Column(pn.Spacer())
        self.dirty = True  # don't use kwargs until source is set 
示例18
def test_all_view():
    """Test that we can construct and view all Alerts"""
    alerts = []
    for alert_type in ALERT_TYPES:
        text = f"""\
            This is a **{alert_type}** alert with [an example link](https://panel.holoviz.org/).
            Give it a click if you like."""
        alert = Alert(text=text, alert_type=alert_type)
        alerts.append(alert)

        assert "alert" in alert.css_classes
        assert f"alert-{alert_type}" in alert.css_classes

    return pn.Column(*alerts, sizing_mode="stretch_width") 
示例19
def __init__(self, data, initial_params={}):
        super().__init__()
        if not isinstance(data, xr.core.dataarray.DataWithCoords):
            raise ValueError("Input should be an xarray data object, not %s" % type(data))
        self.set_data(data)
        self.initial_params = initial_params
        self.control = Control(self.data)
        self.plot_button = pn.widgets.Button(name='Plot', width=200,
                                             disabled=True)
        self.index_selectors = []
        self.graph = pn.Spacer(name='Graph')
        self.taps_graph = hv.Points([])
        self.series_graph = pn.Row(pn.Spacer(name='Series Graph'))
        self.clear_series_button = pn.widgets.Button(name='Clear',
                                                     width=200,
                                                     disabled=True)
        self.output = pn.Row(self.graph,
                             pn.Column(name='Index_selectors'))

        self._register(self.plot_button, 'plot_clicked', 'clicks')
        self.connect('plot_clicked', self.create_graph)

        self._register(self.control.coord_setter.coord_selector, 'set_coords')
        self.connect("set_coords", self.set_coords)

        self._register(self.clear_series_button, 'clear_series', 'clicks')
        self.connect('clear_series', self.clear_series)

        self.control.displayer.connect('variable_selected',
                                       self.check_is_plottable)
        self.control.displayer.connect('variable_selected',
                                       self._link_aggregation_selectors)
        self.control.fields.connect('x', self._link_aggregation_selectors)
        self.control.fields.connect('y', self._link_aggregation_selectors)

        self.panel = pn.Column(self.control.panel,
                               pn.Row(self.plot_button,
                                      self.clear_series_button),
                               self.output,
                               self.series_graph, width_policy='max')

        # To auto-select in case of single variable
        if len(list(self.data.variables)) == 1:
            self.control.displayer.select.value = self.data.variables[0]

        self.control.setup_initial_values(self.initial_params)
        self.taps = []
        self.tap_stream = streams.Tap(transient=True)
        colors = ['#60fffc', '#6da252', '#ff60d4', '#ff9400', '#f4e322',
                  '#229cf4', '#af9862', '#629baf', '#7eed5a', '#e29ec8',
                  '#ff4300']
        self.color_pool = cycle(colors)
        self.clear_points = hv.streams.Stream.define(
            'Clear_points', clear=False)(transient=True) 
示例20
def __init__(self):
        """Initializes the Projection pane."""
        super().__init__()
        self.is_geo = pn.widgets.Checkbox(name='is_geo', value=False,
                                          disabled=True, width=200)
        self.alpha = pn.widgets.FloatSlider(name='alpha', start=0, end=1,
                                            step=0.01, value=0.7, width=200)

        basemap_opts = [None] + list(gvts.tile_sources.keys())
        self.basemap = pn.widgets.Select(name='basemap',
                                         options=basemap_opts,
                                         value=None, width=150)
        self.projection = pn.widgets.Select(name='projection',
                                            options=[None] + sorted(projections_list),
                                            value=None, width=150)
        self.crs = pn.widgets.Select(name='crs',
                                     options=sorted(projections_list),
                                     value='PlateCarree', width=150)
        self.project = pn.widgets.Checkbox(name='project', value=False, width=150)
        self.global_extent = pn.widgets.Checkbox(name='global_extent',
                                                 value=False, width=150)
        self.crs_params = pn.widgets.TextInput(name='crs params',
                                               value="{}", width=400)
        self.proj_params = pn.widgets.TextInput(name='projection params',
                                                value="{}", width=400)

        self.feature_ops = ['None', 'borders', 'coastline', 'grid', 'land',
                            'lakes', 'ocean', 'rivers']
        self.features = pn.widgets.MultiSelect(name='features',
                                               options=self.feature_ops,
                                               value=self.feature_ops[1:], width=150)

        self._register(self.is_geo, 'geo_changed')
        self._register(self.is_geo, 'geo_disabled', 'disabled')
        self._register(self.crs, 'add_crs_params')
        self._register(self.projection, 'add_proj_params')
        self._register(self.basemap, 'show_basemap')

        self.connect('geo_changed', self.setup)
        self.connect('geo_disabled', self.setup)
        self.connect('add_crs_params', self.add_crs_params)
        self.connect('add_proj_params', self.add_proj_params)
        self.connect('show_basemap', self.show_basemap)

        self.panel = pn.Column(
            pn.pane.Markdown(TEXT, margin=(0, 10)),
            pn.Row(self.is_geo,  self.project, self.global_extent),
            pn.Row(self.alpha, self.basemap, self.features),
            pn.Row(self.crs, self.crs_params, name='crs'),
            pn.Row(self.projection, self.proj_params, name='proj'),
            name='Projection')
        self.setup()
        self.add_crs_params(self.crs.value)
        self.add_proj_params(self.projection.value)