本文整理汇总了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
示例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)
示例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 = []
示例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)
示例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)
示例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
示例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)
示例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,
)
)
示例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
示例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
示例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
示例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
示例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.")
示例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
示例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