Python ipywidgets.ToggleButtons() Examples
The following are 12
code examples of ipywidgets.ToggleButtons().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ipywidgets
, or try the search function
.
Example #1
Source File: TSEBIPythonInterface.py From pyTSEB with GNU General Public License v3.0 | 6 votes |
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')
Example #2
Source File: selection.py From notebook-molecular-visualization with Apache License 2.0 | 6 votes |
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')
Example #3
Source File: TSEBIPythonInterface.py From pyTSEB with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: TSEBIPythonInterface.py From pyTSEB with GNU General Public License v3.0 | 5 votes |
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))
Example #5
Source File: TSEBIPythonInterface.py From pyTSEB with GNU General Public License v3.0 | 5 votes |
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
Example #6
Source File: rtlsdr_helper.py From scikit-dsp-comm with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #7
Source File: pyaudio_helper.py From scikit-dsp-comm with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #8
Source File: interfaces.py From notebook-molecular-visualization with Apache License 2.0 | 5 votes |
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)
Example #9
Source File: interfaces.py From notebook-molecular-visualization with Apache License 2.0 | 5 votes |
def __init__(self, xface): self.xface = xface if xface.is_installed(): if xface.version_flag: v = xface.get_installed_version() else: v = INSTALLED else: v = MISSING self.maintext = ipy.HTML( ('<span class="nbv-table-row nbv-width-med nbv-monospace">' ' {xface.name}</span> ' '<span class="nbv-table-row nbv-monospace nbv-width-sm">' ' {localversion}</span> ' '<span class="nbv-table-row nbv-monospace nbv-width-sm">' ' {xface.expectedversion}</span>' '<span class="nbv-width-sm nbv-table-row"> </span>' # empty space ) .format(xface=xface, localversion=v)) self.selector = ipy.ToggleButtons(options=['in docker', 'locally'], value='in docker', button_style='info') self.selector.add_class('nbv-width-lg') self.selector.add_class("nbv-table-row") self.selector.observe(self._toggle, 'value') self.path = ipy.HTML(layout=ipy.Layout(width='150px', font_size='x-small'), value=xface.path if xface.path is not None else '',) self.save_button = ipy.Button(description='Make default', layout=ipy.Layout(width='100px')) self.save_button.on_click(self.save_selection) self.save_button.add_class('nbv-table-row') children = [self.maintext, self.selector, self.save_button] super().__init__(children=children, layout=ipy.Layout(width='100%', align_items='flex-end'))
Example #10
Source File: pylab.py From ipyvolume with MIT License | 4 votes |
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
Example #11
Source File: interfaces.py From notebook-molecular-visualization with Apache License 2.0 | 4 votes |
def __init__(self, xface): self.xface = xface if self.xface.is_installed(): version_string = xface.installed_version() if not version_string: version_string = 'unknown' if version_string != xface.expectedversion: version_string = '<span style="color:red">%s</span>' % version_string self.maintext = ipy.HTML( ('<span class="nbv-table-row nbv-width-med nbv-monospace">' ' {xface.packagename}</span> ' '<span class="nbv-table-row nbv-monospace nbv-width-sm">' ' {localversion}</span> ' '<span class="nbv-table-row nbv-monospace nbv-width-sm">' ' {xface.expectedversion}</span>' '<span class="nbv-width-sm nbv-table-row"> </span>' # empty space ).format(xface=xface, localversion=(version_string if self.xface.is_installed() else MISSING))) if xface.required: self.selector = ipy.ToggleButtons(options=['locally']) elif not xface.is_installed(): self.selector = ipy.ToggleButtons(options=['in docker'], button_style='warning') else: self.selector = ipy.ToggleButtons(options=['locally', 'in docker'], value='in docker' if xface.force_remote else 'locally', button_style='info') self.selector.observe(self._toggle, 'value') self.selector.add_class('nbv-width-lg') self.selector.add_class("nbv-table-row") children = [self.maintext, self.selector] if not self.xface.required and self.xface.is_installed(): self.save_button = ipy.Button(description='Make default') self.save_button.on_click(self.save_selection) self.save_button.add_class('nbv-table-row') children.append(self.save_button) super().__init__(children=children, layout=ipy.Layout(width='100%', align_items='flex-end'))
Example #12
Source File: configurator.py From notebook-molecular-visualization with Apache License 2.0 | 4 votes |
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