当前位置: 首页>>代码示例>>Python>>正文


Python layouts.layout方法代码示例

本文整理汇总了Python中bokeh.layouts.layout方法的典型用法代码示例。如果您正苦于以下问题:Python layouts.layout方法的具体用法?Python layouts.layout怎么用?Python layouts.layout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.layouts的用法示例。


在下文中一共展示了layouts.layout方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def create(self):
        for _ in range(self.num_cameras):
            cam = BokehEventViewerCamera(self)
            cam.enable_pixel_picker(self.num_waveforms)
            cam.create_view_widget()
            cam.update_view_widget()
            cam.add_colorbar()

            self.cameras.append(cam)
            self.camera_layouts.append(cam.layout)

        for iwav in range(self.num_waveforms):
            wav = BokehEventViewerWaveform(self)
            active_color = self.cameras[0].active_colors[iwav]
            wav.fig.select(name="line")[0].glyph.line_color = active_color
            wav.enable_time_picker()
            wav.create_view_widget()
            wav.update_view_widget()

            self.waveforms.append(wav)
            self.waveform_layouts.append(wav.layout)

        self.layout = layout(
            [[column(self.camera_layouts), column(self.waveform_layouts)],]
        ) 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:27,代码来源:bokeh_event_viewer.py

示例2: finish

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def finish(self):
        if not self.disable_server:

            def modify_doc(doc):
                doc.add_root(self.layout)
                doc.title = self.name

                directory = os.path.abspath(os.path.dirname(__file__))
                theme_path = os.path.join(directory, "theme.yaml")
                template_path = os.path.join(directory, "templates")
                doc.theme = Theme(filename=theme_path)
                env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path))
                doc.template = env.get_template("index.html")

            self.log.info(
                "Opening Bokeh application on " "http://localhost:{}/".format(self.port)
            )
            server = Server({"/": modify_doc}, num_procs=1, port=self.port)
            server.start()
            server.io_loop.add_callback(server.show, "/")
            server.io_loop.start() 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:23,代码来源:file_viewer.py

示例3: _meta_wgt

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def _meta_wgt(self):
        wgt_meta = {d: pnwgt.Select(
            name=d, options=v, height=45, width=120)
                    for d, v in self.meta_dicts.items()}
        def make_update_func(meta_name):
            def _update(x):
                self.metas[meta_name] = x.new
                self.update_subs()
            return _update
        for d, wgt in wgt_meta.items():
            cur_update = make_update_func(d)
            wgt.param.watch(cur_update, 'value')
        wgt_update = pnwgt.Button(
            name='Refresh', button_type='primary', height=30, width=120)
        wgt_update.param.watch(self.update_all, 'clicks')
        wgt_load = pnwgt.Button(
            name='Load Data', button_type='danger', height=30, width=120)
        wgt_load.param.watch(self.compute_subs, 'clicks')
        return pn.layout.WidgetBox(
            *(list(wgt_meta.values()) + [wgt_update, wgt_load]),
            width=150) 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:23,代码来源:visualization.py

示例4: create_view_widget

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def create_view_widget(self):
        self.w_view = Select(title="View:", value="", options=[], width=5)
        self.w_view.on_change("value", self.on_view_widget_change)
        self.layout = column([self.w_view, self.layout]) 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:6,代码来源:bokeh_event_viewer.py

示例5: __init__

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self._event = None
        self._event_index = None
        self._event_id = None
        self._telid = None
        self._channel = None

        self.w_next_event = None
        self.w_previous_event = None
        self.w_event_index = None
        self.w_event_id = None
        self.w_goto_event_index = None
        self.w_goto_event_id = None
        self.w_telid = None
        self.w_channel = None
        self.w_dl1_dict = None
        self.wb_extractor = None
        self.layout = None

        self.reader = None
        self.seeker = None
        self.extractor = None
        self.calibrator = None
        self.viewer = None

        self._updating_dl1 = False
        # make sure, gzip files are seekable
        self.config.SimTelEventSource.back_seekable = True 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:31,代码来源:file_viewer.py

示例6: show_layout

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def show_layout(ax, show=True, force_layout=False):
    """Create a layout and call bokeh show."""
    if show is None:
        show = rcParams["plot.bokeh.show"]
    if show:
        import bokeh.plotting as bkp

        layout = create_layout(ax, force_layout=force_layout)
        bkp.show(layout) 
开发者ID:arviz-devs,项目名称:arviz,代码行数:11,代码来源:__init__.py

示例7: show

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def show(self):
        return pn.layout.Column(self.widgets, self.pnplot) 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:4,代码来源:visualization.py

示例8: _widgets

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def _widgets(self):
        w_play = pnwgt.Player(
            length=len(self._f), interval=10,
            value=0, width=650, height=90)
        def play(f):
            if not f.old == f.new:
                self.strm_f.event(f=int(self._f[f.new]))
        w_play.param.watch(play, 'value')
        w_box = pnwgt.Button(
            name='Update Mask',
            button_type='primary',
            width=100,
            height=30)
        w_box.param.watch(self._update_box, 'clicks')
        if not self._layout:
            wgt_meta = {d: pnwgt.Select(
                name=d, options=v, height=45, width=120)
                        for d, v in self.meta_dicts.items()}
            def make_update_func(meta_name):
                def _update(x):
                    self.cur_metas[meta_name] = x.new
                    self._update_subs()
                return _update
            for d, wgt in wgt_meta.items():
                cur_update = make_update_func(d)
                wgt.param.watch(cur_update, 'value')
            wgts = pn.layout.WidgetBox(
                w_box, w_play, *list(wgt_meta.values()))
        else:
            wgts = pn.layout.WidgetBox(
                w_box, w_play)
        return wgts 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:34,代码来源:visualization.py

示例9: _spatial_all_wgt

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def _spatial_all_wgt(self):
        wgt_useAC = pnwgt.Checkbox(
            name='UseAC', value=self._useAC, width=120, height=15)
        def callback_useAC(val):
            self._useAC = val.new
            self.update_AC()
        wgt_useAC.param.watch(callback_useAC, 'value')
        return pn.layout.WidgetBox(wgt_useAC, width=150) 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:10,代码来源:visualization.py

示例10: _create_header

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def _create_header(train_dropdown, inference_dropdown, text_status) -> layouts.Row:
    """Utility function for creating and styling the header row in the UI layout."""

    architect_logo = Div(
        text='<a href="http://nlp_architect.nervanasys.com"> <img border="0" '
        'src="style/nlp_architect.jpg" width="200"></a> by Intel® AI Lab',
        style={
            "margin-left": "500px",
            "margin-top": "20px",
            "font-size": "110%",
            "text-align": "center",
        },
    )
    css_link = Div(
        text="<link rel='stylesheet' type='text/css' href='style/lexicon_manager.css'>",
        style={"font-size": "0%"},
    )

    js_script = Div(text="<input type='file' id='inputOS' hidden='true'>")

    title = Div(
        text="ABSApp",
        style={
            "font-size": "300%",
            "color": "royalblue",
            "font-weight": "bold",
            "margin-left": "500px",
        },
    )

    return row(
        column(
            row(children=[train_dropdown, lexicons_dropdown, inference_dropdown], width=500),
            row(text_status),
        ),
        css_link,
        js_script,
        widgetbox(title, width=900, height=84),
        widgetbox(architect_logo, width=400, height=84),
    ) 
开发者ID:NervanaSystems,项目名称:nlp-architect,代码行数:42,代码来源:absa_solution.py

示例11: __init__

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def __init__(
        self,
        subarray,
        config=None,
        parent=None,
        num_cameras=1,
        num_waveforms=2,
        **kwargs,
    ):
        """
        A class to organise the interface between
        `ctapipe.visualization.bokeh.CameraDisplay`,
        `ctapipe.visualization.bokeh.WaveformDisplay` and
        `ctapipe.core.container.DataContainer`.

        Parameters
        ----------
        config : traitlets.loader.Config
            Configuration specified by config file or cmdline arguments.
            Used to set traitlet values.
            Set to None if no configuration to pass.
        tool : ctapipe.core.Tool
            Tool executable that is calling this component.
            Passes the correct logger to the component.
            Set to None if no Tool to pass.
        num_cameras : int
            Number of camera figures to handle
        num_waveforms : int
            Number of waveform figures to handle
        kwargs
        """
        super().__init__(config=config, parent=parent, **kwargs)

        self._event = None
        self._view = "r0"
        self._telid = None
        self._channel = 0

        self.num_cameras = num_cameras
        self.num_waveforms = num_waveforms

        self.cameras = []
        self.camera_layouts = []
        self.waveforms = []
        self.waveform_layouts = []
        self.subarray = subarray

        self.layout = None 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:50,代码来源:bokeh_event_viewer.py

示例12: create_layout

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def create_layout(ax, force_layout=False):
    """Transform bokeh array of figures to layout."""
    ax = np.atleast_2d(ax)
    subplot_order = rcParams["plot.bokeh.layout.order"]
    if force_layout:
        from bokeh.layouts import gridplot as layout

        ax = ax.tolist()
        layout_args = {
            "sizing_mode": rcParams["plot.bokeh.layout.sizing_mode"],
            "toolbar_location": rcParams["plot.bokeh.layout.toolbar_location"],
        }
    elif any(item in subplot_order for item in ("row", "column")):
        # check number of rows
        match = re.match(r"(\d*)(row|column)", subplot_order)
        n = int(match.group(1)) if match.group(1) is not None else 1
        subplot_order = match.group(2)
        # set up 1D list of axes
        ax = [item for item in ax.ravel().tolist() if item is not None]
        layout_args = {"sizing_mode": rcParams["plot.bokeh.layout.sizing_mode"]}
        if subplot_order == "row" and n == 1:
            from bokeh.layouts import row as layout
        elif subplot_order == "column" and n == 1:
            from bokeh.layouts import column as layout
        else:
            from bokeh.layouts import layout

        if n != 1:
            ax = np.array(ax + [None for _ in range(int(np.ceil(len(ax) / n)) - len(ax))])
            if subplot_order == "row":
                ax = ax.reshape(n, -1)
            else:
                ax = ax.reshape(-1, n)
            ax = ax.tolist()
    else:
        if subplot_order in ("square", "square_trimmed"):
            ax = [item for item in ax.ravel().tolist() if item is not None]
            n = int(np.ceil(len(ax) ** 0.5))
            ax = ax + [None for _ in range(n ** 2 - len(ax))]
            ax = np.array(ax).reshape(n, n)
        ax = ax.tolist()
        if (subplot_order == "square_trimmed") and any(
            all(item is None for item in row) for row in ax
        ):
            from bokeh.layouts import layout

            ax = [row for row in ax if not all(item is None for item in row)]
            layout_args = {"sizing_mode": rcParams["plot.bokeh.layout.sizing_mode"]}
        else:
            from bokeh.layouts import gridplot as layout

            layout_args = {
                "sizing_mode": rcParams["plot.bokeh.layout.sizing_mode"],
                "toolbar_location": rcParams["plot.bokeh.layout.toolbar_location"],
            }
    # ignore "fixed" sizing_mode without explicit width and height
    if layout_args.get("sizing_mode", "") == "fixed":
        layout_args.pop("sizing_mode")
    return layout(ax, **layout_args) 
开发者ID:arviz-devs,项目名称:arviz,代码行数:61,代码来源:__init__.py

示例13: next_image

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def next_image(files, action):
    global file_textbox, button, button_next, button_prev, index
    print("next clicked")
    file_textbox.value = "Processing..."
    renderer = hv.renderer('bokeh')
    if action == 'next':
        index=(index + 1) % len(files)
    else:
        index=(index - 1) % len(files)
    #print("it ", iterator)
    print("index before check",index)
    index = check_errors(files, index, action)
    print("index after check", index)
    print("len", len(files))

    file_name = files[index]
    rgb_images, frame_indices, gripper_status, action_status, gripper_action_label, gripper_action_goal_idx = process_image(file_name)
    print("image loaded")
    print("action goal idx", gripper_action_goal_idx)
    height = int(rgb_images[0].shape[0])
    width = int(rgb_images[0].shape[1])
    start = 0
    end = len(rgb_images) - 1
    print(' End Index of RGB images: ' + str(end))

    def slider_update(attrname, old, new):
        plot.update(slider.value)

    slider = Slider(start=start, end=end, value=0, step=1, title="Frame", width=width)
    slider.on_change('value', slider_update)

    holomap = generate_holo_map(rgb_images, height, width)
    print("generated holomap")
    plot = renderer.get_plot(holomap)
    print("plot rendered")
    gripper_plot, action_plot, gripper_action_plot = load_data_plot(renderer, frame_indices, gripper_status, action_status, gripper_action_label, height, width)
    print("plot loaded..")
    plot_list = [[plot.state], [gripper_plot.state], [action_plot.state]]

    widget_list = [[slider, button, button_prev, button_next], [file_textbox]]

    # "gripper_action" plot, labels based on the gripper opening and closing
    plot_list.append([gripper_action_plot.state])
    layout_child = layout(plot_list + widget_list, sizing_mode='fixed')
    curdoc().clear()
    file_textbox.value = file_name.split("\\")[-1]
    #curdoc().remove_root(layout_child)
    #layout_root.children[0] = layout_child
    curdoc().add_root(layout_child)

#iterator = iter(file_name_list) 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:53,代码来源:stack_player.py

示例14: next_example

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import layout [as 别名]
def next_example(files, action):
    """ load the next example in the dataset
    """
    global file_textbox, button, button_next, button_prev, index, vrep_viz, data, numpy_data
    print("next clicked")
    file_textbox.value = "Processing..."
    renderer = hv.renderer('bokeh')
    if action == 'next':
        index = (index + 1) % len(files)
    else:
        index = (index - 1) % len(files)
    #print("it ", iterator)
    print("index before check", index)
    index = check_errors(files, index, action)
    print("index after check", index)
    print("len", len(files))

    file_name = files[index]
    data, numpy_data = load_example(file_name_list[index])
    rgb_images = numpy_data['rgb_images']
    frame_indices = numpy_data['frame_indices']
    gripper_status = numpy_data['gripper_status']
    action_status = numpy_data['action_status']
    gripper_action_label = numpy_data['gripper_action_label']
    gripper_action_goal_idx = numpy_data['gripper_action_goal_idx']
    print("image loaded")
    print("action goal idx", gripper_action_goal_idx)
    height = int(rgb_images[0].shape[0])
    width = int(rgb_images[0].shape[1])
    start = 0
    end = len(rgb_images)
    print(end)

    def slider_update(attrname, old, new):
        plot.update(slider.value)

    slider = Slider(start=start, end=end, value=0, step=1, title="Frame", width=width)
    slider.on_change('value', slider_update)

    holomap = generate_holo_map(rgb_images, height, width)
    print("generated holomap")
    plot = renderer.get_plot(holomap)
    print("plot rendered")
    gripper_plot, action_plot, gripper_action_plot = load_data_plot(renderer, frame_indices, gripper_status, action_status, gripper_action_label, height, width)
    print("plot loaded..")
    plot_list = [[plot.state], [gripper_plot.state], [action_plot.state]]

    widget_list = [[slider, button, button_prev, button_next], [file_textbox]]

    # "gripper_action" plot, labels based on the gripper opening and closing
    plot_list.append([gripper_action_plot.state])
    layout_child = layout(plot_list + widget_list, sizing_mode='fixed')
    curdoc().clear()
    file_textbox.value = file_name.split("\\")[-1]
    #curdoc().remove_root(layout_child)
    #layout_root.children[0] = layout_child
    curdoc().add_root(layout_child)

#iterator = iter(file_name_list) 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:61,代码来源:vrep_costar_stack.py


注:本文中的bokeh.layouts.layout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。