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
configurator.py 文件源码
python
阅读 35
收藏 0
点赞 0
评论 0
评论列表
文章目录