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


Python ipywidgets.Output方法代码示例

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


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

示例1: circuit_diagram_widget

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def circuit_diagram_widget() -> wid.Box:
    """Create a circuit diagram widget.

    Returns:
        Output widget.
    """
    # The max circuit height corresponds to a 20Q circuit with flat
    # classical register.
    top_out = wid.Output(layout=wid.Layout(width='100%',
                                           height='auto',
                                           max_height='1000px',
                                           overflow='hidden scroll',))

    top = wid.Box(children=[top_out], layout=wid.Layout(width='100%', height='auto'))

    return top 
开发者ID:Qiskit,项目名称:qiskit-terra,代码行数:18,代码来源:library.py

示例2: display

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def display(self, **kwargs):
        """Show plot inside ipywidgets.Output()."""
        output = widgets.Output()

        with output:
            display(self, **kwargs)

        self.outputs.append(output)

        display(output) 
开发者ID:K3D-tools,项目名称:K3D-jupyter,代码行数:12,代码来源:plot.py

示例3: close

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def close(self):
        """Remove plot from all its ipywidgets.Output()-s."""
        for output in self.outputs:
            output.clear_output()

        self.outputs = [] 
开发者ID:K3D-tools,项目名称:K3D-jupyter,代码行数:8,代码来源:plot.py

示例4: display

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def display(self, **kwargs):
        output = widgets.Output()

        with output:
            display(self, **kwargs)

        self.outputs.append(output)

        display(output) 
开发者ID:K3D-tools,项目名称:K3D-jupyter,代码行数:11,代码来源:transfer_function_editor.py

示例5: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def __init__(
        self,
        alerts: pd.DataFrame,
        action: Callable[..., None] = None,
        columns: List[str] = None,
        auto_display: bool = False,
    ):
        """
        Create a new instance of AlertSelector.

        Parameters
        ----------
        alerts : pd.DataFrame
            DataFrame of alerts.
        action : Callable[..., None], optional
            Optional function to execute for each selected alert.
            (the default is None)
        columns : List[str], optional
            Override the default column names to use from `alerts`
            (the default is ['StartTimeUtc', 'AlertName',
            'CompromisedEntity', 'SystemAlertId'])
        auto_display : bool, optional
            Whether to display on instantiation (the default is False)

        """
        self._w_output = widgets.Output(layout={"border": "1px solid black"})
        super().__init__(alerts, action, columns, auto_display) 
开发者ID:microsoft,项目名称:msticpy,代码行数:29,代码来源:nbwidgets.py

示例6: properties_widget

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def properties_widget(circuit: QuantumCircuit) -> wid.VBox:
    """Create a HTML table widget with header for a given quantum circuit.

    Args:
        circuit: Input quantum circuit.

    Returns:
        Output widget.
    """
    properties = wid.VBox(children=[property_label,
                                    circuit_data_table(circuit)],
                          layout=wid.Layout(width='40%',
                                            height='auto'))
    return properties 
开发者ID:Qiskit,项目名称:qiskit-terra,代码行数:16,代码来源:library.py

示例7: screenshot

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def screenshot(
    width=None,
    height=None,
    format="png",
    fig=None,
    timeout_seconds=10,
    output_widget=None,
    headless=False,
    devmode=False,
):
    """Save the figure to a PIL.Image object.

    :param int width: the width of the image in pixels
    :param int height: the height of the image in pixels
    :param format: format of output data (png, jpeg or svg)
    :type fig: ipyvolume.widgets.Figure or None
    :param fig: if None use the current figure
    :type timeout_seconds: int
    :param timeout_seconds: maximum time to wait for image data to return
    :type output_widget: ipywidgets.Output
    :param output_widget: a widget to use as a context manager for capturing the data
    :param bool headless: if True, use headless chrome to take screenshot
    :param bool devmode: if True, attempt to get index.js from local js/dist folder
    :return: PIL.Image

    """
    assert format in ['png', 'jpeg', 'svg'], "image format must be png, jpeg or svg"
    data = _screenshot_data(
        timeout_seconds=timeout_seconds,
        output_widget=output_widget,
        format=format,
        width=width,
        height=height,
        fig=fig,
        headless=headless,
        devmode=devmode,
    )
    f = StringIO(data)
    return PIL.Image.open(f) 
开发者ID:maartenbreddels,项目名称:ipyvolume,代码行数:41,代码来源:pylab.py

示例8: savefig

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def savefig(
    filename, width=None, height=None, fig=None, timeout_seconds=10, output_widget=None, headless=False, devmode=False
):
    """Save the figure to an image file.

    :param str filename: must have extension .png, .jpeg or .svg
    :param int width: the width of the image in pixels
    :param int height: the height of the image in pixels
    :type fig: ipyvolume.widgets.Figure or None
    :param fig: if None use the current figure
    :param float timeout_seconds: maximum time to wait for image data to return
    :param ipywidgets.Output output_widget: a widget to use as a context manager for capturing the data
    :param bool headless: if True, use headless chrome to save figure
    :param bool devmode: if True, attempt to get index.js from local js/dist folder
    """
    __, ext = os.path.splitext(filename)
    format = ext[1:]
    assert format in ['png', 'jpeg', 'svg'], "image format must be png, jpeg or svg"
    with open(filename, "wb") as f:
        f.write(
            _screenshot_data(
                timeout_seconds=timeout_seconds,
                output_widget=output_widget,
                format=format,
                width=width,
                height=height,
                fig=fig,
                headless=headless,
                devmode=devmode,
            )
        ) 
开发者ID:maartenbreddels,项目名称:ipyvolume,代码行数:33,代码来源:pylab.py

示例9: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def __init__(self, debug, cad_width, height):
        self.debug_output = Output()
        self.debug = debug
        self.cad_width = cad_width
        self.height = height
        self.view = None 
开发者ID:bernhard-42,项目名称:jupyter-cadquery,代码行数:8,代码来源:replay.py

示例10: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def __init__(self, data, view, s):
        if data == None:
            self.rows = []
            self.hboxes = []
        else:
            self.rows = data.rows

        if s[0] != 1 or s[1] != 1:
            if data == None: # Intialize subplot array
                cnt = 0
                for r in range(s[0]):
                    row = []
                    for c in range(s[1]):
                        row.append(Output())
                        cnt += 1
                    self.rows.append(row)

                for r in self.rows:
                    hbox = HBox(r)
                    if rendertype == "JUPYTER":
                        display(hbox)
                    self.hboxes.append(hbox)

            out = self.rows[int(s[2]/s[1])][s[2]%s[1]]
            if rendertype == "JUPYTER":
                with out:
                    display(view._renderer)
            self.rows[int(s[2]/s[1])][s[2]%s[1]] = view 
开发者ID:skoch9,项目名称:meshplot,代码行数:30,代码来源:plot.py

示例11: thread_cell

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def thread_cell(line, cell, local_ns=None):
        t = Thread(target=executor, args=(cell, globals(), sys._getframe(2).f_locals))
        out = widgets.Output(layout={'border': '1px solid gray'})
        output_registry[t.name] = out
        t.start()
        return out 
开发者ID:RoboStack,项目名称:jupyter-ros,代码行数:8,代码来源:ipy.py

示例12: subscribe

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def subscribe(topic, msg_type, callback):
    """
    Subscribes to a specific topic in another thread, but redirects output!

    @param topic The topic
    @param msg_type The message type
    @param callback The callback

    @return Jupyter output widget
    """

    if subscriber_registry.get(topic):
        print("Removing previous callback, only one redirection possible right now", file=sys.stderr)
        subscriber_registry[topic].unregister()

    out = widgets.Output(layout={'border': '1px solid gray'})
    subscriber_registry[topic] = rospy.Subscriber(topic, msg_type, callback)
    output_registry[topic] = out

    btn = widgets.Button(description='Stop')

    def stop_start_subscriber(x):
        if output_registry.get(topic) is not None:
            subscriber_registry[topic].unregister()
            del output_registry[topic]
            btn.description = 'Start'
        else:
            output_registry[topic] = out
            subscriber_registry[topic] = rospy.Subscriber(topic, msg_type, callback)
            btn.description = 'Stop'

    btn.on_click(stop_start_subscriber)
    btns = widgets.HBox((btn, ))
    vbox = widgets.VBox((btns, out))
    return vbox 
开发者ID:RoboStack,项目名称:jupyter-ros,代码行数:37,代码来源:pubsub.py

示例13: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def __init__(self, **kwargs):
        super(CaptumInsights, self).__init__(**kwargs)
        self.insights_config = self.visualizer.get_insights_config()
        self.out = widgets.Output()
        with self.out:
            print("Captum Insights widget created.") 
开发者ID:pytorch,项目名称:captum,代码行数:8,代码来源:widget.py

示例14: __init__

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def __init__(self,
                 work,
                 args=(),
                 kw={},
                 max=100,
                 title=None,
                 tags=None,
                 comment='',
                 auto_save=None,
                 no_bar=False):
        title = work.__name__ if title is None else title
        self.ctx = contextvars.copy_context()
        self.parent = self.ctx.get(current_job, None)
        if auto_save is None:
            self.auto_save = True if self.parent is None else False
        else:
            self.auto_save = auto_save
        self.data = DataCollector(title, tags=tags, comment=comment, job=self)
        self.bar = ProgressBar(max=max, description=title, hiden=no_bar)
        self.out = widgets.Output()
        display(self.out)
        self.work_code = None
        code = compile(inspect.getsource(work),
                       f'defintion of {work.__name__}', 'single')
        for c in code.co_consts:
            if isinstance(c, type(code)) and c.co_name == work.__name__:
                self.work_code = c
                break
        self.work = work
        self.args = args
        self.kw = kw 
开发者ID:feihoo87,项目名称:QuLab,代码行数:33,代码来源:job.py

示例15: circuit_data_table

# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Output [as 别名]
def circuit_data_table(circuit: QuantumCircuit) -> wid.HTML:
    """Create a HTML table widget for a given quantum circuit.

    Args:
        circuit: Input quantum circuit.

    Returns:
        Output widget.
    """

    ops = circuit.count_ops()

    num_nl = circuit.num_nonlocal_gates()

    html = "<table>"
    html += """<style>
table {
    font-family: "IBM Plex Sans", Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%;
    border-left: 2px solid #212121;
}

th {
    text-align: left;
    padding: 5px 5px 5px 5px;
    width: 100%;
    background-color: #3700BE;
    color: #fff;
    font-size: 16px;
    border-left: 2px solid #3700BE;
}

td {
    font-family: "IBM Plex Mono", monospace;
    text-align: left;
    padding: 5px 5px 5px 5px;
    width: 100%;
    font-size: 13px;
    font-weight: medium;
}

tr:nth-child(even) {background-color: #f6f6f6;}
</style>"""
    html += "<tr><th>{}</th><th></tr>".format(circuit.name)
    html += "<tr><td>Width</td><td>{}</td></tr>".format(circuit.width())
    html += "<tr><td>Depth</td><td>{}</td></tr>".format(circuit.depth())
    html += "<tr><td>Total Gates</td><td>{}</td></tr>".format(sum(ops.values()))
    html += "<tr><td>Non-local Gates</td><td>{}</td></tr>".format(num_nl)
    html += "</table>"

    out_wid = wid.HTML(html)
    return out_wid 
开发者ID:Qiskit,项目名称:qiskit-terra,代码行数:55,代码来源:library.py


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