How to use the ipywidgets.Layout 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 rheiland / xml2jupyter / tests / user_params.py View on Github external
desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(description='', disabled=True, layout=desc_button_layout) 
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(description='', disabled=True, layout=desc_button_layout) 
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(description='', disabled=True, layout=desc_button_layout) 
        desc_button6.style.button_color = 'tan'

        row1 = [param_name1, self.tumor_radius, units_button1, desc_button1] 
        row2 = [param_name2, self.oncoprotein_mean, units_button2, desc_button2] 
        row3 = [param_name3, self.oncoprotein_sd, units_button3, desc_button3] 
        row4 = [param_name4, self.oncoprotein_min, units_button4, desc_button4] 
        row5 = [param_name5, self.oncoprotein_max, units_button5, desc_button5] 
        row6 = [param_name6, self.random_seed, units_button6, desc_button6] 

        box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%')
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)

        self.tab = VBox([
          box1,
          box2,
          box3,
          box4,
          box5,
          box6,
        ])
github exa-analytics / exatomic / exatomic / widgets / widget_utils.py View on Github external
def __init__(self, control, content, **kwargs):
        self.show = kwargs.pop('show', False)
        self.indent = 5
        self.level = kwargs.pop('level', 0)
        pw = 98 - self.level * self.indent
        self._slo = Layout(width=str(pw - self.indent) + '%')
        self._plo = Layout(width=str(pw) + '%')
        self._init(control, content)
        lo = kwargs.pop('layout', None)
        lo = Layout(width='100%', align_items='flex-end')
        super(Folder, self).__init__(
            children=self._get(), layout=lo, **kwargs)
        self.active = True
        self.disabled = False
github yt-project / yt / yt / fields / field_type_container.py View on Github external
with _box:
                    display(Markdown(data = "```python\n" +
                        textwrap.dedent(fobj.get_source()) + "\n```"))
                values = inspect.getclosurevars(fobj._function).nonlocals
                _var_window.value = _fill_values(values)
            return _change_field
        flist = ipywidgets.Select(options = names,
                layout = ipywidgets.Layout(height = '95%'))
        source = ipywidgets.Output(layout = ipywidgets.Layout(
            width = '100%', height = '9em'))
        var_window = ipywidgets.HTML(value = 'Empty')
        var_box = ipywidgets.Box(layout = ipywidgets.Layout(
            width = '100%', height = '100%', overflow_y = 'scroll'))
        var_box.children = [var_window]
        ftype_tabs = ipywidgets.Tab(children = [source, var_box],
                layout = ipywidgets.Layout(flex = '2 1 auto',
                            width = 'auto', height = '95%'))
        ftype_tabs.set_title(0, "Source")
        ftype_tabs.set_title(1, "Variables")
        flist.observe(change_field(self, source, var_window), "value")
        display(ipywidgets.HBox([flist, ftype_tabs],
            layout = ipywidgets.Layout(height = '14em')))
github Qiskit / qiskit-ibmq-provider / qiskit / providers / ibmq / jupyter / dashboard / backend_widget.py View on Github external
qubit_size = 12
        line_width = 3
    if n_qubits > 50:
        qubit_size = 12
        line_width = 3

    _gmap = iplot_gate_map(backend, figsize=(150, 150),
                           qubit_size=qubit_size,
                           line_width=line_width,
                           qubit_color='#031981',
                           line_color='#031981',
                           label_qubits=False,
                           as_widget=True)

    gmap = wid.Box(children=[_gmap],
                   layout=wid.Layout(width='auto',
                                     justify_content='center',
                                     align_content='center',
                                     ))

    # Get basic device stats
    t1_units = props['qubits'][0][0]['unit']
    avg_t1 = round(sum([q[0]['value'] for q in props['qubits']])/n_qubits, 1)
    avg_t2 = round(sum([q[1]['value'] for q in props['qubits']])/n_qubits, 1)

    if n_qubits != 1:
        sum_cx_err = 0
        num_cx = 0
        for gate in props['gates']:
            if gate['gate'] == 'cx':
                for param in gate['parameters']:
                    if param['name'] == 'gate_error':
github Jupyter-Kale / kale / kale / workflow_widgets.py View on Github external
def __init__(self, workflow, worker_pool_widget):
        super().__init__()

        # Define variables
        self.workflow = workflow
        self.worker_pool_widget = worker_pool_widget
        self._fig_layout = ipw.Layout(width='400px', height='600px')
        self._xs = bq.LinearScale()
        self._ys = bq.LinearScale()
        self._scales = {'x': self._xs, 'y': self._ys}
        mgin = 10

        self.displayed_task = None
        # Link which binds readme text of selected task to displayed value
        self._task_readme_link = None

        # Define elements
        self._metadata_template = """
        Node name: {name}
        <br>
        Last modified: {date}
        <br>
        Description: {word}
github ricklupton / floweaver / floweaver / sankey_data.py View on Github external
if margins is None:
            margins = {
                'top': 25,
                'bottom': 10,
                'left': 130,
                'right': 130,
            }

        value = self.to_json(format='widget')
        widget = SankeyWidget(nodes=value['nodes'],
                              links=value['links'],
                              order=value['order'],
                              groups=value['groups'],
                              align_link_types=align_link_types,
                              layout=Layout(width=str(width), height=str(height)),
                              margins=margins)

        if debugging:
            output = Output()
            def callback(_, d):
                with output:
                    clear_output()
                if not d:
                    return
                link = [l for l in self.links
                        if l.source == d['source']
                        and l.target == d['target']
                        and l.type == d['type']]
                assert len(link) == 1
                link = link[0]
                with output:
github Xilinx / meta-petalinux / recipes-examples / pm-notebooks / pm-notebooks / pmutil / hotplug.py View on Github external
def _setup_buttons_container(buttons_list):
    '''
        Returns an instance of "Box" which contains all "Button" widgets
    '''
    box_layout = Layout(display='flex',
                        flex_flow='column',
                        align_items='stretch',
                        border='solid',
                        width='100%')
    return Box(children=buttons_list,
               layout=box_layout)
github UCLA-Plasma-Simulation-Group / pyVisOS / osh5visipy.py View on Github external
def _add_one_ct_lvl_opt(self, lvl, co):
        lvl, cp, db = self._get_contour_opt_wgt(lvl, co, '100px', '150px')
        widgets.jslink((lvl, 'disabled'), (self.ct_level, 'disabled'))
        widgets.jslink((cp, 'disabled'), (self.ct_colorpicker, 'disabled'))
        db.on_click(self._remove_ct_lvl_opt)
        lvl_wgt = widgets.HBox([lvl, cp, db], layout=Layout(border='solid 1px'))
        self.ct_opts_dict[db] = lvl_wgt
        self.ct_opts_list.children += (lvl_wgt,)
github singnet / semantic-vision / experiments / opencog / pattern_matcher_vqa / gui_helpers.py View on Github external
def display(self):
        hlayout = Layout(display='flex',
                         flex_flow='row',
                         align_items='stretch',
                         border='none',
                         width='100%')

        vbox = VBox(children=[self.text, self.label_answer, self.label_query, self.label_expression])
        vbox.layout.width = '70%'
        interact = widgets.interactive(self._next_image, idx=(0, len(self.images) - 1))
        interact.layout.height = '550px'
        self.image_output = interact.out
        display.display(HBox(children=[interact, vbox], layout=hlayout))
github Autodesk / notebook-molecular-visualization / nbmolviz / viewers / orbital_viewer.py View on Github external
value=0.01, step=0.00075,
                                               readout_format='.4f',
                                               layout=ipy.Layout(width=layout.width))
        traitlets.link((self.isoval_selector, 'value'), (self, 'isoval'))

        # Opacity selector
        opacity_label = ipy.Label('Opacity:')
        self.opacity_selector = ipy.FloatSlider(min=0.0, max=1.0,
                                               value=0.8, step=0.01,
                                               readout_format='.2f',
                                               layout=ipy.Layout(width=layout.width))
        traitlets.link((self.opacity_selector, 'value'), (self, 'orb_opacity'))

        # Resolution selector
        resolution_label = ipy.Label("Grid resolution:", layout=ipy.Layout(width=layout.width))
        self.orb_resolution = ipy.Text(layout=ipy.Layout(width='75px',
                                                         positioning='bottom'))
        self.orb_resolution.value = str(self.numpoints)
        self.resolution_button = ipy.Button(description='Update resolution')
        self.resolution_button.on_click(self.change_resolution)
        traitlets.directional_link((self, 'numpoints'), (self.orb_resolution, 'value'),
                                   transform=str)

        self.uipane = ipy.VBox([self.status_element,
                                orbtype_label, self.type_dropdown,
                                orblist_label, self.orblist,
                                isoval_label, self.isoval_selector,
                                opacity_label, self.opacity_selector,
                                resolution_label, self.orb_resolution, self.resolution_button])
        self.new_orb_type()
        self.type_dropdown.observe(self.new_orb_type, 'value')
        return self.uipane