本文整理汇总了Python中ipywidgets.IntText方法的典型用法代码示例。如果您正苦于以下问题:Python ipywidgets.IntText方法的具体用法?Python ipywidgets.IntText怎么用?Python ipywidgets.IntText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipywidgets
的用法示例。
在下文中一共展示了ipywidgets.IntText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntText [as 别名]
def create_widget(callback_func, init_params, image_filename=None):
"""
Displays ipywidgets for initialization of a QuantumSystem object.
Parameters
----------
callback_func: function
callback_function depends on all the parameters provided as keys (str) in the parameter_dict, and is called upon
changes of values inside the widgets
init_params: {str: value, str: value, ...}
names and values of initialization parameters
image_filename: str, optional
file name for circuit image to be displayed alongside the qubit
Returns
-------
"""
widgets = {}
box_list = []
for name, value in init_params.items():
label = ipywidgets.Label(value=name)
if isinstance(value, float):
enter_widget = ipywidgets.FloatText
else:
enter_widget = ipywidgets.IntText
widgets[name] = enter_widget(value=value, description='', disabled=False)
box_list.append(ipywidgets.HBox([label, widgets[name]], layout=ipywidgets.Layout(justify_content='flex-end')))
if image_filename:
file = open(image_filename, "rb")
image = file.read()
image_widget = ipywidgets.Image(value=image, format='png', layout=ipywidgets.Layout(width='400px'))
ui_widget = ipywidgets.HBox([ipywidgets.VBox(box_list), ipywidgets.VBox([image_widget])])
else:
ui_widget = ipywidgets.VBox(box_list)
out = ipywidgets.interactive_output(callback_func, widgets)
display(ui_widget, out)
示例2: _widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntText [as 别名]
def _widget(self):
import ipywidgets
if self.min is None and self.max is None:
return ipywidgets.IntText(value=self.value)
else:
return ipywidgets.BoundedIntText(
value=self.value,
min=self.min or -(2 ** 63),
max=self.max or (2 ** 63 - 1),
)
示例3: _init_widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntText [as 别名]
def _init_widget(self):
"""构建AbuFactorSellNDay策略参数界面"""
self.description = widgets.Textarea(
value=u'持有N天后卖出策略:\n'
u'卖出策略,不管交易现在什么结果,买入后只持有N天\n'
u'需要与特定\'买入策略\'形成配合\n,'
u'单独使用N天卖出策略意义不大',
description=u'N天卖出',
disabled=False,
layout=self.description_layout
)
sell_n_label = widgets.Label(u'设定买入后只持有天数,默认1', layout=self.label_layout)
self.sell_n = widgets.IntText(
value=1,
description=u'N天',
disabled=False
)
sell_n_box = widgets.VBox([sell_n_label, self.sell_n])
is_sell_today_label = widgets.Label(u'设定买入n天后,当天还是隔天卖出', layout=self.label_layout)
self.is_sell_today = widgets.Dropdown(
options={u'N天后隔天卖出': False, u'N天后当天卖出': True},
value=False,
description=u'当天隔天:',
)
is_sell_today_box = widgets.VBox([is_sell_today_label, self.is_sell_today])
self.widget = widgets.VBox([self.description, sell_n_box, is_sell_today_box, self.add_box],
# border='solid 1px',
layout=self.widget_layout)
示例4: _init_widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntText [as 别名]
def _init_widget(self):
"""构建AbuPickStockNTop策略参数界面"""
self.description = widgets.Textarea(
value=u'涨跌幅top N选股因子策略:\n'
u'选股周期上对多只股票涨跌幅进行排序,选取top n个股票做为交易目标:\n'
u'(只对在股池中选定的symbol序列生效,对全市场回测暂时不生效)\n',
description=u'top N涨跌',
disabled=False,
layout=self.description_layout
)
n_top_label = widgets.Label(u'设定选取top个交易目标数量,默认3', layout=self.label_layout)
self.n_top = widgets.IntText(
value=3,
description=u'TOP N',
disabled=False
)
self.n_top_box = widgets.VBox([n_top_label, self.n_top])
direction_top_label1 = widgets.Label(u'direction_top参数的意义为选取方向:', layout=self.label_layout)
direction_top_label2 = widgets.Label(u'默认值为正:即选取涨幅最高的n_top个股票', layout=self.label_layout)
direction_top_label3 = widgets.Label(u'可设置为负:即选取跌幅最高的n_top个股票', layout=self.label_layout)
self.direction_top = widgets.Dropdown(
options={u'正(涨幅)': 1, u'负(跌幅)': -1},
value=1,
description=u'选取方向:',
)
self.direction_top_box = widgets.VBox([direction_top_label1, direction_top_label2, direction_top_label3,
self.direction_top])
self.widget = widgets.VBox([self.description, self.n_top_box, self.direction_top_box,
self.xd_box, self.reversed_box, self.add_box],
# border='solid 1px',
layout=self.widget_layout)
示例5: _widget
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntText [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
示例6: __init__
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntText [as 别名]
def __init__(self, paramdef):
super(ParamSelector, self).__init__(layout=ipy.Layout(display='flex',
flex_flow='nowrap',
align_content='stretch'))
self.paramdef = paramdef
children = []
self.name = ipy.HTML("<p style='text-align:right'>%s:</p>" % paramdef.displayname,
layout=ipy.Layout(width='200px'))
children.append(self.name)
if paramdef.choices:
self.selector = ipy.Dropdown(options=paramdef.choices, **self.WIDGETKWARGS)
elif paramdef.type == bool:
self.selector = ipy.ToggleButtons(options=[True, False], **self.WIDGETKWARGS)
elif paramdef.units:
self.selector = UnitText(units=paramdef.units, **self.WIDGETKWARGS)
elif paramdef.type == float:
self.selector = ipy.FloatText(**self.WIDGETKWARGS)
elif paramdef.type == int:
self.selector = ipy.IntText(**self.WIDGETKWARGS)
elif paramdef.type == str:
self.selector = ipy.Text(**self.WIDGETKWARGS)
else:
self.selector = ReadOnlyRepr(**self.WIDGETKWARGS)
children.append(self.selector)
children = [self.name, self.selector]
self.default_button = None
if paramdef.default:
self.default_button = ipy.Button(description='Default',
tooltip='Set to default: %s' % self.paramdef.default,
layout=ipy.Layout(width='75px'))
self.default_button.on_click(self.default)
children.append(self.default_button)
self.default()
self.help_link = None
if paramdef.help_url:
self.help_link = ipy.HTML('<a href="%s" target="_blank">?</a>' % paramdef.help_url)
children.append(self.help_link)
self.children = children
示例7: add_widgets
# 需要导入模块: import ipywidgets [as 别名]
# 或者: from ipywidgets import IntText [as 别名]
def add_widgets(msg_instance, widget_dict, widget_list, prefix=''):
"""
Adds widgets.
@param msg_type The message type
@param widget_dict The form list
@param widget_list The widget list
@return widget_dict and widget_list
"""
# import only here so non ros env doesn't block installation
from genpy import Message
if msg_instance._type.split('/')[-1] == 'Image':
w = widgets.Text()
widget_dict['img'] = w
w_box = widgets.HBox([widgets.Label(value='Image path:'), w])
widget_list.append(w_box)
return widget_dict, widget_list
for idx, slot in enumerate(msg_instance.__slots__):
attr = getattr(msg_instance, slot)
s_t = msg_instance._slot_types[idx]
w = None
if s_t in ['float32', 'float64']:
w = widgets.FloatText()
if s_t in ['int8', 'uint8', 'int32', 'uint32', 'int64', 'uint64']:
w = widgets.IntText()
if s_t in ['string']:
w = widgets.Text()
if isinstance(attr, Message):
widget_list.append(widgets.Label(value=slot))
widget_dict[slot] = {}
add_widgets(attr, widget_dict[slot], widget_list, slot)
if w:
widget_dict[slot] = w
w_box = widgets.HBox([widgets.Label(value=slot, layout=widgets.Layout(width="100px")), w])
widget_list.append(w_box)
return widget_dict, widget_list