本文整理匯總了Python中ipywidgets.ToggleButtons方法的典型用法代碼示例。如果您正苦於以下問題:Python ipywidgets.ToggleButtons方法的具體用法?Python ipywidgets.ToggleButtons怎麽用?Python ipywidgets.ToggleButtons使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ipywidgets
的用法示例。
在下文中一共展示了ipywidgets.ToggleButtons方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: resistances_time_series
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def resistances_time_series(self):
'''Widgets for resistance model selection'''
self.w_res = widgets.ToggleButtons(
description='Select TSEB model to run:',
options={
'Kustas & Norman 1999': 0,
'Choudhury & Monteith 1988': 1,
'McNaughton & Van der Hurk': 2},
value=self.res,
width=300)
self.w_KN_b = widgets.BoundedFloatText(
value=self.KN_b, min=0, description='KN99 b', width=80)
self.w_KN_c = widgets.BoundedFloatText(
value=self.KN_c, min=0, description='KN99 c', width=80)
self.w_KN_C_dash = widgets.BoundedFloatText(
value=self.KN_C_dash, min=0, max=9999, description="KN99 C'", width=80)
self.KN_params_box = widgets.HBox([self.w_KN_b, self.w_KN_c, self.w_KN_C_dash])
self.res_page = widgets.VBox([self.w_res, self.KN_params_box], background_color='#EEE')
示例2: __init__
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def __init__(self, mol):
super().__init__(mol)
self._atomset = collections.OrderedDict()
self.atom_listname = ipy.Label('Selected atoms:', layout=ipy.Layout(width='100%'))
self.atom_list = ipy.SelectMultiple(options=list(self.viewer.selected_atom_indices),
layout=ipy.Layout(height='150px'))
traitlets.directional_link(
(self.viewer, 'selected_atom_indices'),
(self.atom_list, 'options'),
self._atom_indices_to_atoms
)
self.select_all_atoms_button = ipy.Button(description='Select all atoms')
self.select_all_atoms_button.on_click(self.select_all_atoms)
self.select_none = ipy.Button(description='Clear all selections')
self.select_none.on_click(self.clear_selections)
self.representation_buttons = ipy.ToggleButtons(options=['stick','ribbon', 'auto', 'vdw'],
value='auto')
self.representation_buttons.observe(self._change_representation, 'value')
示例3: select_model
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def select_model(self):
''' Widget to select the TSEB model'''
self.w_model = widgets.ToggleButtons(
description='Select TSEB model to run:',
options={
'Priestley Taylor': 'TSEB_PT',
'Dual-Time Difference': 'DTD',
'Component Temperatures': 'TSEB_2T'},
value=self.model)
示例4: resistances_image
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def resistances_image(self):
'''Widgets for resistance model selection'''
self.w_res = widgets.ToggleButtons(
description='Select TSEB model to run:',
options={
'Kustas & Norman 1999': 0,
'Choudhury & Monteith 1988': 1,
'McNaughton & Van der Hurk': 2},
value=self.res,
width=300)
self.w_PT_But = widgets.Button(
description='Browse Initial alphaPT Image')
self.w_PT = widgets.Text(description=' ', value=str(self.max_PT), width=500)
self.w_KN_b_But = widgets.Button(description='Browse Resistance Parameter b Image')
self.w_KN_b = widgets.Text(
value=str(self.KN_b), description=' ', width=500)
self.w_KN_c_But = widgets.Button(description=('Browse Resistance Parameter c image'))
self.w_KN_c = widgets.Text(
value=str(self.KN_c), description='(m s-1 K-1/3)', width=500)
self.w_KN_C_dash_But = widgets.Button(description=("Browse Resistance Parameter C' Image"))
self.w_KN_C_dash = widgets.Text(
value=str(self.KN_C_dash), description="s1/2 m-1", width=500)
self.KN_params_box = widgets.VBox([widgets.HTML('Select resistance parameter b image or type a constant value'),
widgets.HBox([self.w_KN_b_But, self.w_KN_b]),
widgets.HTML('Select resistance parameter c image or type a constant value'),
widgets.HBox([self.w_KN_c_But, self.w_KN_c]),
widgets.HTML('Select resistance parameter C\' image or type a constant value'),
widgets.HBox([self.w_KN_C_dash_But, self.w_KN_C_dash])], background_color='#EEE')
self.res_page = widgets.VBox([self.w_res, self.KN_params_box], background_color='#EEE')
self.w_KN_b_But.on_click(
lambda b: self._on_input_clicked(b, 'Resistance Parameter b', self.w_KN_b))
self.w_KN_c_But.on_click(
lambda b: self._on_input_clicked(b, 'Resistance Parameter c', self.w_KN_c))
self.w_KN_C_dash_But.on_click(
lambda b: self._on_input_clicked(b, 'Resistance Parameter C\'', self.w_KN_C_dash))
示例5: calc_G_options
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def calc_G_options(self):
'''Widgets for method for computing soil heat flux'''
self.w_G_form = widgets.ToggleButtons(
description='Select method for soil heat flux',
options={
'Ratio of soil net radiation': 1,
'Constant or measured value': 0,
'Time dependent (Santanelo & Friedl)': 2},
value=self.G_form,
width=300)
self.w_Gratio = widgets.BoundedFloatText(
value=self.Gratio, min=0, max=1, description='G ratio (G/Rn)', width=80)
self.w_Gconstant = widgets.FloatText(
value=self.Gconstant, description='Value (W m-2)', width=80)
self.w_Gconstant.visible = False
self.w_Gconstanttext = widgets.HTML(
value="Set G value (W m-2), ignored if G is present in the input file")
self.w_Gconstanttext.visible = False
self.w_Gconstant.visible = False
self.w_G_amp = widgets.BoundedFloatText(
value=self.G_amp, min=0, max=1, description='Amplitude (G/Rn)', width=80)
self.w_G_amp.visible = False
self.w_G_phase = widgets.BoundedFloatText(
value=self.G_phase, min=-24, max=24, description='Time Phase (h)', width=80)
self.w_G_phase.visible = False
self.w_G_shape = widgets.BoundedFloatText(
value=self.G_shape, min=0, max=24, description='Time shape (h)', width=80)
self.w_G_shape.visible = False
示例6: interactive_FM_Rx
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def interactive_FM_Rx(self,fc=103.9e6,gain=40,audio_out=1,audio_buffsize=4096,audio_fs=48000):
'''
Sets up interactive mono FM example
'''
self.set_fs(2.4e6)
self.set_fc(fc)
self.set_gain(gain)
self.set_audio_in(0)
self.set_audio_out(audio_out)
self.set_audio_buffsize(audio_buffsize)
self.set_audio_fs(audio_fs)
self.togglebutts = ToggleButtons(
options=['Start Streaming', 'Stop Streaming'],
description = ' ',
value = 'Stop Streaming',
)
self.togglebutts.style.button_width = "400px"
self.togglebutts.style.description_width = "1px"
self.play = interactive(self._interaction, Stream = self.togglebutts)
title = widgets.Output()
title.append_stdout("Interactive FM Receiver")
display(title)
display(self.play)
self._interact_audio_gain()
self._interact_frequency(self.fc/1e6)
示例7: interactive_stream
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def interactive_stream(self,Tsec = 2, numChan = 1):
"""
Stream audio with start and stop radio buttons
Interactive stream is designed for streaming audio through this object using
a callback function. This stream is threaded, so it can be used with ipywidgets.
Click on the "Start Streaming" button to start streaming and click on "Stop Streaming"
button to stop streaming.
Parameters
----------
Tsec : stream time in seconds if Tsec > 0. If Tsec = 0, then stream goes to infinite
mode. When in infinite mode, the "Stop Streaming" radio button or Tsec.stop() can be
used to stop the stream.
numChan : number of channels. Use 1 for mono and 2 for stereo.
"""
self.Tsec = Tsec
self.numChan = numChan
self.interactiveFG = 1
self.play = interactive(self.interaction,Stream = ToggleButtons(
options=['Start Streaming', 'Stop Streaming'],
description = ' ',
value = 'Stop Streaming') )
display(self.play)
示例8: __init__
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def __init__(self):
from moldesign.compute import packages
self.toggle = ipy.ToggleButtons(options=['Python libs', 'Executables'],
value='Python libs')
self.toggle.observe(self.switch_pane, 'value')
self.pyheader = ipy.HTML(
'<span class="nbv-table-header nbv-width-med">Package</span> '
'<span class="nbv-table-header nbv-width-sm">Local version</span> '
'<span class="nbv-table-header nbv-width-sm">Expected version</span>'
'<span class="nbv-width-sm"> </span>' # empty space
'<span class="nbv-table-header nbv-width-lg">'
' Run calculations...</span>'
'<span class="nbv-table-header nbv-width-med"> </span>')
self.python_libs = ipy.VBox([self.pyheader] + [PyLibConfig(p) for p in packages.packages])
self.exeheader = ipy.HTML(
'<span class="nbv-table-header nbv-width-med">Program</span> '
'<span class="nbv-table-header nbv-width-sm">Local version</span> '
'<span class="nbv-table-header nbv-width-sm">Docker version</span>'
'<span class="nbv-width-sm"> </span>' # empty space
'<span class="nbv-table-header nbv-width-lg">'
' Run calculations...</span>'
'<span class="nbv-table-header nbv-width-med"> </span>')
self.executables = ipy.VBox([self.exeheader] + [ExeConfig(p) for p in packages.executables])
self.children = [self.toggle, self.python_libs]
super().__init__(children=self.children)
示例9: figure
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [as 別名]
def figure(
key=None,
width=400,
height=500,
lighting=True,
controls=True,
controls_vr=False,
controls_light=False,
debug=False,
**kwargs
):
"""Create a new figure if no key is given, or return the figure associated with key.
:param key: Python object that identifies this figure
:param int width: pixel width of WebGL canvas
:param int height: .. height ..
:param bool lighting: use lighting or not
:param bool controls: show controls or not
:param bool controls_vr: show controls for VR or not
:param bool debug: show debug buttons or not
:return: :any:`Figure`
"""
if key is not None and key in current.figures:
current.figure = current.figures[key]
current.container = current.containers[key]
elif isinstance(key, ipv.Figure) and key in current.figures.values():
key_index = list(current.figures.values()).index(key)
key = list(current.figures.keys())[key_index]
current.figure = current.figures[key]
current.container = current.containers[key]
else:
current.figure = ipv.Figure(width=width, height=height, **kwargs)
current.container = ipywidgets.VBox()
current.container.children = [current.figure]
if key is None:
key = uuid.uuid4().hex
current.figures[key] = current.figure
current.containers[key] = current.container
if controls:
# stereo = ipywidgets.ToggleButton(value=current.figure.stereo, description='stereo', icon='eye')
# l1 = ipywidgets.jslink((current.figure, 'stereo'), (stereo, 'value'))
# current.container.children += (ipywidgets.HBox([stereo, ]),)
pass # stereo and fullscreen are now include in the js code (per view)
if controls_vr:
eye_separation = ipywidgets.FloatSlider(value=current.figure.eye_separation, min=-10, max=10, icon='eye')
ipywidgets.jslink((eye_separation, 'value'), (current.figure, 'eye_separation'))
current.container.children += (eye_separation,)
if controls_light:
globals()['controls_light']()
if debug:
show = ipywidgets.ToggleButtons(options=["Volume", "Back", "Front", "Coordinate"])
current.container.children += (show,)
# ipywidgets.jslink((current.figure, 'show'), (show, 'value'))
traitlets.link((current.figure, 'show'), (show, 'value'))
return current.figure
示例10: __init__
# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import ToggleButtons [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