How to use the ipywidgets.Checkbox 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 menpo / menpowidgets / menpowidgets / options.py View on Github external
def __init__(self, channel_options, render_function=None, style='minimal'):
        # Parse given options
        channel_options, channels = self._parse_options_dict(channel_options)

        # Create children
        slice_options = {'command': channels,
                         'length': channel_options['n_channels']}
        self.channels_wid = SlicingCommandWidget(
            slice_options, description='Channels:', render_function=None,
            example_visible=True, continuous_update=False,
            orientation='horizontal')
        self.masked_checkbox = ipywidgets.Checkbox(
            value=channel_options['masked_enabled'], description='Masked',
            margin='0.1cm')
        self.rgb_checkbox = ipywidgets.Checkbox(
            value=(channel_options['n_channels'] == 3 and
                   channel_options['channels'] is None),
            description='RGB', margin='0.1cm')
        self.sum_checkbox = ipywidgets.Checkbox(
            value=channel_options['sum_enabled'], description='Sum',
            margin='0.1cm')
        self.glyph_checkbox = ipywidgets.Checkbox(
            value=channel_options['glyph_enabled'], description='Glyph',
            margin='0.1cm')
        self.glyph_block_size_text = ipywidgets.BoundedIntText(
            description='Block size', min=1, max=25,
            value=channel_options['glyph_block_size'], width='1.5cm')
        self.glyph_use_negative_checkbox = ipywidgets.Checkbox(
github menpo / menpowidgets / menpowidgets / options.py View on Github external
def __init__(self, landmark_options, render_function=None,
                 style='minimal'):
        # Parse given options
        landmark_options, group_idx = self._parse_landmark_options_dict(
            landmark_options)

        # Create children
        # Render landmarks checkbox and no landmarks message
        self.no_landmarks_msg = ipywidgets.Latex(
            value='No landmarks available.')
        self.render_landmarks_checkbox = ipywidgets.Checkbox(
            description='Render landmarks',
            value=landmark_options['render_landmarks'], margin='0.3cm')

        # Create group description, dropdown and slider
        self.group_description = ipywidgets.Latex(value='Group', margin='0.1cm')
        dropdown_dict = OrderedDict()
        for gn, gk in enumerate(landmark_options['group_keys']):
            dropdown_dict[gk] = gn
        self.group_slider = ipywidgets.IntSlider(
            min=0, max=len(landmark_options['group_keys']) - 1, margin='0.1cm',
            font_size=0, value=group_idx, width='3cm', continuous_update=False)
        self.group_dropdown = ipywidgets.Dropdown(
            options=dropdown_dict, description='', value=group_idx,
            margin='0.1cm')
        self.group_selection_box = ipywidgets.HBox(
            children=[self.group_description, self.group_slider,
github UCLA-Plasma-Simulation-Group / pyVisOS / osh5visipy.py View on Github external
widgets.HBox([self.vmin_wgt, self.if_vmin_auto]), self.if_clip_cm, self.linthresh, self.linscale]))

        # find out default value for norm_selector
        norm_avail = {'Log': ln_wgt, 'Normalize': n_wgt, 'Power': pn_wgt, 'SymLog': sln_wgt}
        self.norm_selector = widgets.Dropdown(options=norm_avail, style={'description_width': 'initial'},
                                              value=norm_avail.get(norm, n_wgt), description='Normalization:')
        self.__old_norm = self.norm_selector.value
        # additional care for LorNorm()
        self.__handle_lognorm()
#         self.vmin_wgt.value, self.vlogmin_wgt.value, self.vmax_wgt.value = vmin, logvmin, vmax
        # re-plot button
        self.norm_btn_wgt = widgets.Button(description='Apply', disabled=False, tooltip='Update normalization', icon='refresh')
        tab.append(self.get_tab_data())

        # # # -------------------- Tab1 --------------------------
        self.if_xrange_auto = widgets.Checkbox(value=True, description='Auto xrange', layout=_items_layout, style={'description_width': 'initial'})
        self.if_yrange_auto = widgets.Checkbox(value=True, description='Auto yrange', layout=_items_layout, style={'description_width': 'initial'})
        self.apply_range_btn = widgets.Button(description='Apply', disabled=False, \
                                              tooltip='set range. (* this will delete all overlaid plots *)', icon='refresh')
        self.axis_lim_wgt = widgets.HBox([self.if_xrange_auto, self.if_yrange_auto, self.apply_range_btn])
        # x axis
        xmin, xmax, xinc, ymin, ymax, yinc = self.__get_xy_minmax_delta()
        if convert_xaxis:
            self.xconv, xunit = data.axes[1].punit_convert_factor()
        else:
            self.xconv, xunit = 1.0, data.axes[1].units
        xmin *= self.xconv
        xmax *= self.xconv
        self.x_min_wgt = widgets.BoundedFloatText(value=xmin, min=xmin, max=xmax, step=xinc * self.xconv/2, description='xmin:',
                                                  disabled=True, layout=_items_layout, style={'description_width': 'initial'})
        self.x_max_wgt = widgets.BoundedFloatText(value=xmax, min=xmin, max=xmax, step=xinc * self.xconv/2, description='xmax:',
                                                  disabled=True, layout=_items_layout, style={'description_width': 'initial'})
github RoboStack / jupyter-ros / jupyros / ros_widgets.py View on Github external
    @return jupyter widget for display
    """
    widget_list = []
    bag_player.sp = None
    ###### Fields #########################################################
    bgpath_txt = widgets.Text()
    bgpath_box = widgets.HBox([widgets.Label("Bag file path:"), bgpath_txt])
    bgpath_txt.value = bagfile
    play_btn = widgets.Button(description="Play", icon='play')
    pause_btn = widgets.Button(description="Pause", icon='pause', disabled=True)
    step_btn = widgets.Button(description="Step", icon='step-forward', disabled=True)
    ibox = widgets.Checkbox(description="Immediate")
    lbox = widgets.Checkbox(description="Loop")
    clockbox = widgets.Checkbox(description="Clock")
    dzbox = widgets.Checkbox(description="Duration")
    kabox = widgets.Checkbox(description="Keep alive")
    start_float = widgets.FloatText(value=0)
    start_box = widgets.HBox([widgets.Label("Start time:"), start_float])
    que_int = widgets.IntText(value=100)
    que_box = widgets.HBox([widgets.Label("Queue size:"), que_int])
    factor_float = widgets.FloatText(value=1)
    factor_box = widgets.HBox([widgets.Label("Multiply the publish rate by:"), factor_float])
    delay_float = widgets.FloatText(value=0)
    delay_box = widgets.HBox([widgets.Label("Delay after every advertise call:"), delay_float])
    duration_float = widgets.FloatText(value=0)
    duration_box = widgets.HBox([dzbox, widgets.Label("Duration in secs:"), duration_float])
    out_box = widgets.Output(layout={'border': '1px solid black'})
    ######## Play Button ##################################################
    def ply_clk(arg):
        if play_btn.description == "Play":
            info_dict = yaml.load(subprocess.Popen(['rosbag', 'info', '--yaml', bgpath_txt.value],
                stdout=subprocess.PIPE).communicate()[0])
github UCLA-Plasma-Simulation-Group / pyVisOS / osh5visipy.py View on Github external
layout={'width': 'initial'}, style={'description_width': 'initial'})
        self.anaxmax = widgets.BoundedFloatText(value=ymax, min=ymin, max=ymax, step=yinc, description='to',
                                                layout={'width': 'initial'}, style={'description_width': 'initial'})
        widgets.jslink((self.anaxmin, 'min'), (self.y_min_wgt, 'value'))
        widgets.jslink((self.anaxmin, 'max'), (self.anaxmax, 'value'))
        widgets.jslink((self.anaxmin, 'step'), (self.y_step_wgt, 'value'))
        widgets.jslink((self.anaxmax, 'min'), (self.anaxmin, 'value'))
        widgets.jslink((self.anaxmax, 'max'), (self.y_max_wgt, 'value'))
        widgets.jslink((self.anaxmax, 'step'), (self.y_step_wgt, 'value'))
        self.xana_add = widgets.Button(description='Add', tooltip='Add analysis as x line plot', layout={'width': 'initial'})
        xlinegroup = widgets.HBox([self.xananame, self.xanaopts, self.anaxmin, self.anaxmax, self.xana_add], layout=Layout(border='solid 1px'))
        self.xlineout_fixedwidth_ticks = widgets.Checkbox(value=False, description='fixed width ticker;', layout=_items_layout, style={'description_width': 'initial'})
        self.xlineout_ticker_format = widgets.Text(value='', description='Ticker Format: %', placeholder='1.2f', continuous_update=False,
                                                   layout=_items_layout, style={'description_width': 'initial'})
        self.xlineout_list_wgt = widgets.Box(children=[], layout=overlay_item_layout)
        self.xline_auto_range = widgets.Checkbox(value=True, description='Auto plot range;', layout=_items_layout, style={'description_width': 'initial'})
        self.xline_style = widgets.Dropdown(options=['-', '--', '-.', ':'], value='-', description='linestyle:', layout=_items_layout, style={'description_width': 'initial'})
        self.xline_range_min = widgets.FloatText(value=self.vmin_wgt.value, description='min:', disabled=True, layout=_items_layout, style={'description_width': 'initial'})
        self.xline_range_max = widgets.FloatText(value=self.vmax_wgt.value, description='max:', disabled=True, layout=_items_layout, style={'description_width': 'initial'})
        widgets.jslink((self.xline_range_min, 'disabled'), (self.xline_auto_range, 'value'))
        widgets.jslink((self.xline_range_max, 'disabled'), (self.xline_auto_range, 'value'))
        xticks = widgets.HBox([self.xlineout_fixedwidth_ticks, self.xlineout_ticker_format, self.xline_auto_range,
                               self.xline_range_min, self.xline_range_max, self.xline_style], layout=Layout(flex='1 1 auto', width='auto'))
        # list of x lines plotted
        self.xlineout_tab = widgets.VBox([xticks, widgets.HBox([widgets.HBox([self.xlineout_wgt, self.add_xlineout_btn],
                                                                             layout=Layout(border='solid 1px', flex='1 1 auto', width='auto')),
                                                        xlinegroup]), self.xlineout_list_wgt])
        # y lineout
        self.ylineout_wgt = widgets.BoundedFloatText(value=xmin, min=xmin, max=xmax, style={'description_width': 'initial'},
                                                     step=xinc, description=self.xlabel.value, layout=_items_layout)
        widgets.jslink((self.ylineout_wgt, 'description'), (self.xlabel, 'value'))
        widgets.jslink((self.ylineout_wgt, 'min'), (self.x_min_wgt, 'value'))
github gee-community / gee_tools / geetools / ui / ipytools.py View on Github external
for asset in content:
            path = asset['id']
            ty = asset['type']
            if ty == 'Image':
                ee.data.deleteAsset(path)
                widget.value += 'deleting {} ({})<br>'.format(path, ty)
            else:
                # clear output
                widget.value = ''
                recrusive_delete_asset_to_widget(path, widget)
        # delete empty colletion and/or folder
        ee.data.deleteAsset(assetId)


class CheckRow(HBox):
    checkbox = Instance(Checkbox)
    widget = Instance(Widget)

    def __init__(self, widget, **kwargs):
        self.checkbox = Checkbox(indent=False,
                                layout=Layout(flex='1 1 20', width='auto'))
        self.widget = widget
        super(CheckRow, self).__init__(children=(self.checkbox, self.widget),
                                       **kwargs)
        self.layout = Layout(display='flex', flex_flow='row',
                             align_content='flex-start')

    @observe('widget')
    def _ob_wid(self, change):
        new = change['new']
        self.children = (self.checkbox, new)
github rheiland / PhysiCell_tools / pc4nanobio / bin / nano.py View on Github external
# TODO: assert these next 2 values sum to 1.0
        self.metab_aero = HBox([BoundedFloatText(min=0,max=1,step=0.1,
            description='Aerobic', disabled=True, #style={'description_width': 'initial'},
            layout=Layout(width=constWidth),
            ), ], layout=Layout(width=width_cell_params_units))
        self.metab_glyco = HBox([BoundedFloatText(min=0,max=1,step=0.1,
            description='Glycolytic', disabled=True, #style={'description_width': 'initial'},
            layout=Layout(width=constWidth),
        ), ], layout=Layout(width=width_cell_params_units))
        
#        metabolism_stuff = VBox([label_metabolism, HBox([self.metab_aero,self.metab_glyco])])

        #-------------------------------
#        label_motility = Label('Motility:')
        self.motility_response = Checkbox(
            description='Motility', disabled=True, 
            layout=Layout(width='200px'),
        )
        self.motility_response.observe(self.motility_response_cb)

        self.is_motile = Checkbox(
            description='motile', disabled=True, 
            layout=Layout(width='200px'),
        )
        self.is_motile.observe(self.is_motile_cb)

        self.bias = HBox([BoundedFloatText(max=1, step=0.01,
            description='bias', # style={'description_width': 'initial'},
            layout=Layout(width=constWidth),
        ), ], layout=Layout(width=width_cell_params_units))
github mwcraig / reducer / reducer / gui.py View on Github external
'{}'.format(toggle_type.keys()))
        super(ToggleContainer, self).__init__(*args, **kwd)
        self._toggle_container = widgets.Box()
        # Boxes no longer have a description in ipywidgets 7 so add one here
        self._toggle_container.description = 'toggle holder'
        self._checkbox = toggle_types[toggle_type](description=self.description)
        self._toggle_container.children = [self._checkbox]
        self._container = widgets.VBox()
        # Boxes no longer have a description in ipywidgets 7 so add one here
        self._container.description = "Toggle-able container"
        self._state_monitor_container = widgets.Box(visibility='hidden')
        # Boxes no longer have a description in ipywidgets 7 so add one here
        self._state_monitor_container.description = "For internal use only"
        self._state_monitor_container.layout.visibility = 'hidden'
        self._state_monitor_container.display = 'none'
        self._state_monitor = widgets.Checkbox(visibility='hidden')
        self._state_monitor.layout.visibility = 'hidden'
        self._state_monitor.layout.display = 'none'
        self._state_monitor_container.children = [self._state_monitor]

        self.children = [
            self._toggle_container,
            self._container,
            self._state_monitor,
        ]

        self._link_children()
        self._child_notify_parent_on_change(self.toggle)
        # Cache the current value of container's display before we start switching
        # visibility.
        self._display_cache = self._container.layout.display
        # Make absolutely sure a change happens...
github HCsoft-RD / shaolin / shaolin / core / kungfu.py View on Github external
def _get_bool_child(children):
        bools = []
        bool_types = (wid.Checkbox,wid.ToggleButton,wid.Valid)
        for c in children:
            if isinstance(c.widget,bool_types):
                bools.append(c)
        return bools