本文整理汇总了Python中ipywidgets.Accordion方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.Accordion方法的具体用法?Python ipywidgets.Accordion怎么用?Python ipywidgets.Accordion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipywidgets
的用法示例。
在下文中一共展示了ipywidgets.Accordion方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: subscriber_ui
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def subscriber_ui(self, labels):
"""
构建订阅的已添加的买入策略ui初始化
:param labels: list序列内部对象str用来描述解释
"""
# 添加针对指定买入策略的卖出策略
self.accordion = widgets.Accordion()
buy_factors_child = []
for label in labels:
buy_factors_child.append(widgets.Label(label,
layout=widgets.Layout(width='300px', align_items='stretch')))
self.buy_factors = widgets.SelectMultiple(
options=[],
description=u'已添加的买入策略:',
disabled=False,
layout=widgets.Layout(width='100%', align_items='stretch')
)
buy_factors_child.append(self.buy_factors)
buy_factors_box = widgets.VBox(buy_factors_child)
self.accordion.children = [buy_factors_box]
示例2: handle_object_inspector
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def handle_object_inspector(self, **change):
""" Handle function for the Object Inspector Widget
DEPRECATED
"""
event = change['type'] # event type
thewidget = change['widget']
if event == 'click': # If the user clicked
# Clear children // Loading
thewidget.children = [HTML('wait a second please..')]
thewidget.set_title(0, 'Loading...')
widgets = []
i = 0
for name, obj in self.EELayers.items(): # for every added layer
the_object = obj['object']
try:
properties = the_object.getInfo()
wid = create_accordion(properties) # Accordion
wid.selected_index = None # this will unselect all
except Exception as e:
wid = HTML(str(e))
widgets.append(wid)
thewidget.set_title(i, name)
i += 1
thewidget.children = widgets
示例3: __init__
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def __init__(self, **kwargs):
desc = 'Select one or more layers'
super(CustomInspector, self).__init__(description=desc, **kwargs)
self.selector = SelectMultiple()
self.main = Accordion()
self.children = [self.selector, self.main]
示例4: _widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def _widget(self):
from ipywidgets import Accordion
accordion = Accordion(children=[log._widget() for log in self.values()])
[accordion.set_title(i, title) for i, title in enumerate(self.keys())]
return accordion
示例5: info2map
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def info2map(map):
""" Add an information Tab to a map displayed with `geetools.ipymap`
module
:param map: the Map where the tab will be added
:type map: geetools.ipymap.Map
:return:
"""
try:
from ipywidgets import Accordion
except:
print('Cannot use ipytools without ipywidgets installed\n'
'ipywidgets.readthedocs.io')
map.addTab('BAP Inspector', info_handler, Accordion())
示例6: build_job_viewer
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def build_job_viewer():
"""Builds the job viewer widget
Returns:
widget: Job viewer.
"""
acc = widgets.Accordion(children=[widgets.VBox(layout=widgets.Layout(max_width='710px',
min_width='710px'))],
layout=widgets.Layout(width='auto',
max_width='750px',
max_height='500px',
overflow_y='scroll',
overflow_x='hidden'))
acc.set_title(0, 'IBMQ Jobs')
acc.selected_index = None
acc.layout.visibility = 'hidden'
display(acc)
acc._dom_classes = ['job_widget']
display(Javascript("""$('div.job_widget')
.detach()
.appendTo($('#header'))
.css({
'z-index': 999,
'position': 'fixed',
'box-shadow': '5px 5px 5px -3px black',
'opacity': 0.95,
'float': 'left,'
})
"""))
acc.layout.visibility = 'visible'
return acc
示例7: control_panel
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def control_panel(ric = None):
from ipywidgets import Button, HTML,HBox,Accordion
from IPython.core.display import display
def fmt(inp):
if inp is None:
return "--"
elif type(inp) is float:
return "{:.4g}".format(inp)
else:
return str(inp)
if ric is None:
ric = qkit.ric
def update_instrument_params(b):
insdict = ric.get_all_instrument_params()
for ins in sorted(insdict):
if not ins in b.accordions:
b.accordions[ins] = Accordion()
table = "<table style='line-height:180%'>" # <tr style='font-weight:bold'><td> Parameter </td><td>Value</td></tr>
for p in sorted(insdict[ins]):
table += "<tr><td style='text-align:right;padding-right:10px'>" + str(p) + "</td><td>" + fmt(insdict[ins][p][0]) + insdict[ins][p][
1] + "</td></tr>"
table += """</table>"""
b.accordions[ins].children = [HTML(table)]
b.accordions[ins].set_title(0, ins)
for child in b.accordions.keys():
if child not in insdict:
del b.accordions[child]
b.hbox.children = b.accordions.values()
update_button = Button(description="Update")
update_button.on_click(update_instrument_params)
update_button.accordions = {}
update_button.hbox = HBox()
stop_button = Button(description="Stop measurement")
stop_button.on_click(lambda b: qkit.ric.stop_measure())
stop_button.button_style = "danger"
update_instrument_params(update_button)
display(HBox([update_button,stop_button]),update_button.hbox)
示例8: __init__
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def __init__(self,
children: Optional[List] = None,
**kwargs: Any):
"""AccordionWithThread constructor.
Args:
children: A list of widgets to be attached to the accordion.
**kwargs: Additional keywords to be passed to ``ipywidgets.Accordion``.
"""
children = children or []
super(AccordionWithThread, self).__init__(children=children, **kwargs)
self._thread = None
# Devices VBox.
self._device_list = None # type: Optional[wid.VBox]
示例9: image
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def image(image, region=None, visualization=None, name=None,
dimensions=(500, 500), do_async=None):
""" Preview an Earth Engine Image """
if do_async is None:
do_async = CONFIG.get('do_async')
start = time()
if name:
label = '{} (Image)'.format(name)
loading = 'Loading {} preview...'.format(name)
else:
label = 'Image Preview'
loading = 'Loading preview...'
formatdimension = "x".join([str(d) for d in dimensions])
wid = Accordion([Label(loading)])
wid.set_title(0, loading)
def compute(image, region, visualization):
if not region:
region = tools.geometry.getRegion(image)
else:
region = tools.geometry.getRegion(region)
params = dict(dimensions=formatdimension, region=region)
if visualization:
params.update(visualization)
url = image.getThumbURL(params)
req = requests.get(url)
content = req.content
rtype = req.headers['Content-type']
if rtype in ['image/jpeg', 'image/png']:
img64 = base64.b64encode(content).decode('utf-8')
src = '<img src="data:image/png;base64,{}"></img>'.format(img64)
result = HTML(src)
else:
result = Label(content.decode('utf-8'))
return result
def setAccordion(acc):
widget = compute(image, region, visualization)
end = time()
elapsed = end-start
acc.children = [widget]
elapsed = utils.format_elapsed(elapsed)
acc.set_title(0, '{} [{}]'.format(label, elapsed))
if do_async:
thread = threading.Thread(target=setAccordion, args=(wid,))
thread.start()
else:
setAccordion(wid)
return wid
示例10: _widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import Accordion [as 别名]
def _widget(self):
""" Create IPython widget for display within a notebook """
try:
return self._cached_widget
except AttributeError:
pass
if self.asynchronous:
return None
try:
from ipywidgets import Layout, VBox, HBox, IntText, Button, HTML, Accordion
except ImportError:
self._cached_widget = None
return None
layout = Layout(width="150px")
title = HTML("<h2>GatewayCluster</h2>")
status = HTML(self._widget_status(), layout=Layout(min_width="150px"))
request = IntText(0, description="Workers", layout=layout)
scale = Button(description="Scale", layout=layout)
minimum = IntText(0, description="Minimum", layout=layout)
maximum = IntText(0, description="Maximum", layout=layout)
adapt = Button(description="Adapt", layout=layout)
accordion = Accordion(
[HBox([request, scale]), HBox([minimum, maximum, adapt])],
layout=Layout(min_width="500px"),
)
accordion.selected_index = None
accordion.set_title(0, "Manual Scaling")
accordion.set_title(1, "Adaptive Scaling")
@scale.on_click
def scale_cb(b):
with log_errors():
self.scale(request.value)
@adapt.on_click
def adapt_cb(b):
self.adapt(minimum=minimum.value, maximum=maximum.value)
name = HTML("<p><b>Name: </b>{0}</p>".format(self.name))
elements = [title, HBox([status, accordion]), name]
if self.dashboard_link is not None:
link = HTML(
'<p><b>Dashboard: </b><a href="{0}" target="_blank">{0}'
"</a></p>\n".format(self.dashboard_link)
)
elements.append(link)
self._cached_widget = box = VBox(elements)
self._status_widget = status
return box