本文整理匯總了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