How to use the ipywidgets.ToggleButton function in ipywidgets

To help you get started, we’ve selected a few ipywidgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github michellab / BioSimSpace / python / BioSimSpace / Gateway / _node.py View on Github external
# Create a widget button to indicate whether the requirement value
        # has been set.
        button = _widgets.Button(
            tooltip="The input requirement is unset.",
            button_style="warning",
            icon="fa-exclamation-triangle",
            layout=_widgets.Layout(flex="1 1 auto", width="auto"),
            disabled=False,
        )

        # Add a Jupyter widget for each of the supported requirement types.

        # Boolean.
        if type(input) is _Boolean:
            # Create a Jupyter toggle button.
            widget = _widgets.ToggleButton(
                value=False,
                description=name,
                tooltip=input.getHelp(),
                button_style="",
                icon="check",
                disabled=False
            )

            # Add the 'set' indicator button to the widget.
            widget._button = button

            # Flag that the widget is unset.
            widget._is_set = False

            # Get the default value.
            default = input.getDefault()
github menpo / menpowidgets / menpowidgets / options.py View on Github external
plus_description='fa-plus', loop_enabled=loop_enabled,
                text_editable=True)
        else:
            raise ValueError('index_style should be either slider or buttons')
        self.index_wid.style(box_style=None, border_visible=False,
                             padding=0, margin='0.1cm')

        # Create other widgets
        self.play_stop_toggle = ipywidgets.ToggleButton(
            icon='fa-play', description='', value=False, margin='0.1cm')
        self._toggle_play_style = 'success'
        self._toggle_stop_style = 'danger'
        if style == 'minimal':
            self._toggle_play_style = ''
            self._toggle_stop_style = ''
        self.play_options_toggle = ipywidgets.ToggleButton(
            icon='fa-wrench', description='', value=False, margin='0.1cm')
        self.loop_checkbox = ipywidgets.Checkbox(
            description='Loop', value=loop_enabled)
        self.interval_text = ipywidgets.FloatText(description='Interval (sec)',
                                                  value=interval, width='1.4cm')
        self.loop_interval_box = ipywidgets.VBox(
            children=[self.interval_text, self.loop_checkbox], visible=False,
            margin='0.1cm', padding='0.1cm', border_color='black',
            border_style='solid', border_width=1)
        self.play_options_box = ipywidgets.HBox(
            children=[self.play_options_toggle, self.loop_interval_box])
        self.animation_box = ipywidgets.HBox(
            children=[self.play_stop_toggle, self.play_options_box])

        # Create final widget
        children = [self.index_wid, self.animation_box]
github scanner-research / esper-tv / app / esper / identity_clusters.py View on Github external
def get_refresh_button():
        ref_button = widgets.ToggleButton(
            layout=widgets.Layout(width='auto'),
            style=WIDGET_STYLE_ARGS,
            description='Refresh selections',
            disabled=False,
            button_style='warning'
        )
        def on_refresh(b):
            _clear_selected_clusters()
            clear_output()
            _selection_buttons(False)
            _display_clusters(clusters, examples_per_cluster)  
        ref_button.observe(on_refresh)
        return ref_button
github scanlime / fygimbal / fywidgets.py View on Github external
def __init__(self, loopFunc, **kw):
        self.thread = None
        self.loopFunc = loopFunc
        ipywidgets.interact(self.toggler, x=ipywidgets.ToggleButton(**kw))
github RedPitaya / jupyter / redpitaya / app / generator.py View on Github external
self.trig_src = 0
            self.mode      = 'PERIODIC'
            self.amplitude = 0
            self.offset    = 0
            self.set_waveform()
            self.frequency = self._f_one
            self.phase     = 0
            self.start()
            self.trigger()

            fl_min = math.log10(self._f_min)
            fl_max = math.log10(self._f_max)
            fl_one = math.log10(self._f_one)

            # create widgets
            self.w_enable    = ipw.ToggleButton (value=False, description='output enable')
            self.w_waveform  = ipw.ToggleButtons(value='sin', options=['sin', 'square', 'sawtooth'], description='waveform')
            self.w_duty      = ipw.FloatSlider  (value=0.5, min=0.0, max=1.0, step=0.01, description='duty')
            self.w_amplitude = ipw.FloatSlider  (value=0, min=-1.0, max=+1.0, step=0.02, description='amplitude')
            self.w_offset    = ipw.FloatSlider  (value=0, min=-1.0, max=+1.0, step=0.02, description='offset')
            self.w_frequency = ipw.FloatSlider  (value=fl_one, min=fl_min, max=fl_max, step=0.02, description='frequency')
            self.w_phase     = ipw.FloatSlider (value=0, min=0, max=360, step=1, description='phase')

            # style widgets
            self.w_enable.layout    = ipw.Layout(width='100%')
            self.w_duty.layout      = ipw.Layout(width='100%')
            self.w_amplitude.layout = ipw.Layout(width='100%')
            self.w_offset.layout    = ipw.Layout(width='100%')
            self.w_frequency.layout = ipw.Layout(width='100%')
            self.w_phase.layout     = ipw.Layout(width='100%')

            self.w_enable.observe   (self.clb_enable   , names='value')
github JoaoFelipe / snowballing / snowballing / graph.py View on Github external
def create_category(self, name, attr, value, color, font_color):
        """Create category widget"""
        VIS = ["none", ""]
        widget = self.toggle_widgets[attr] = ToggleButton(value=value, description=name)
        wcolor = self.color_widgets[attr] = ColorPicker(value=color, description=name, width="180px")
        wfont_color = self.font_color_widgets[attr] = ColorPicker(value=font_color, width="110px")
        def visibility(*args):
            """" Toggles visibility of category """
            self._display_stack += 1
            wcolor.layout.display = VIS[int(widget.value)]
            wfont_color.layout.display = VIS[int(widget.value)]
            self.display()
        widget.observe(visibility, "value")
        wcolor.observe(self.update_widget, "value")
        wfont_color.observe(self.update_widget, "value")
        visibility()
github asvcode / Vision_UI / vision_ui2.py View on Github external
print(BOLD + BLUE + "Choose Augmentation Parameters: ")
    button_paras = widgets.Button(description='Confirm', button_style='success')

    aug_paras.hh = widgets.ToggleButton(value=False, description='Erase', button_style='info',
                                      style=style)
    aug_paras.cc = widgets.ToggleButton(value=False, description='Contrast', button_style='info',
                                      style=style)
    aug_paras.dd = widgets.ToggleButton(value=False, description='Rotate', button_style='info',
                                      style=style)
    aug_paras.ee = widgets.ToggleButton(value=False, description='Warp', button_style='info',
                                      style=style)
    aug_paras.ff = widgets.ToggleButton(value=False, description='Bright', button_style='info',
                                      style=style)
    aug_paras.gg = widgets.ToggleButton(value=False, description='DihedralFlip', button_style='info',
                                      style=style)
    aug_paras.ii = widgets.ToggleButton(value=False, description='Zoom', button_style='info',
                                      style=style)

    qq = widgets.HBox([aug_paras.hh, aug_paras.cc, aug_paras.dd, aug_paras.ee, aug_paras.ff, aug_paras.gg, aug_paras.ii])
    display(qq)
    display(button_paras)
    aug_par = widgets.Output()
    display(aug_par)
    def on_button_two_click(b):
        with aug_par:
            clear_output()
            aug()
            aug_dash_choice()
    button_paras.on_click(on_button_two_click)
github pypr / pysph / pysph / tools / ipy_viewer.py View on Github external
(self.play_button, 'value')
        )
        self.delay_box = widgets.FloatText(
            value=1.0,
            description='Delay',
            disabled=False,
            layout=widgets.Layout(width='160px', display='flex')
        )
        self.save_figure = widgets.Text(
                value='',
                placeholder='example.png',
                description='Save figure',
                disabled=False,
                layout=widgets.Layout(width='240px', display='flex')
        )
        self.save_all_plots = widgets.ToggleButton(
                value=False,
                description='Save all plots!',
                disabled=False,
                tooltip='Saves the corresponding plots for all the' +
                        ' frames in the presently set styling.',
                icon='',
                layout=widgets.Layout(display='flex'),
        )
        self.solver_time = widgets.HTML(
                value=self.time,
                description='Solver time:',
        )
        self.print_config = widgets.Button(
            description='print present config.',
            tooltip='Prints the configuration dictionary ' +
                    'for the current viewer state',
github HCsoft-RD / shaolin / shaolin / benders / graph.py View on Github external
names='value')

        self.toggle_nod = widgets.ToggleButton(description='Node Map',
                                               value=True, padding=6)

        self.toggle_nod.observe(self.on_tognod_change, names='value')

        self.toggle_edg = widgets.ToggleButton(description='Edge Map',
                                               value=True, padding=6)
        self.toggle_edg.observe(self.on_togedg_change, names='value')

        self.toggle_def = widgets.ToggleButton(description='Free',
                                               value=False, padding=6)
        self.toggle_def.observe(self.on_togdef_change, names='value')

        self.toggle_graph = widgets.ToggleButton(description='Graph',
                                                 value=False, padding=6)
        self.toggle_graph.observe(self.on_toggraph_change, names='value')

        self.toggle_scale = widgets.ToggleButton(description='Scale',
                                                 value=False, padding=6)
        self.toggle_scale.observe(self.on_togscale_change, names='value')

        self.btn_box = widgets.HBox(children=[self.toggle_nod,
                                              self.toggle_edg,
                                              self.toggle_def,
                                              self.toggle_graph,
                                              self.toggle_scale], padding=6)
        title_html = '''<div style="font-size:22px;
                                                        font-weight: bold; 
                                                        text-align:right;" class="kf-graph-gplot">
                                                        Graph Manager</div>'''