當前位置: 首頁>>代碼示例>>Python>>正文


Python ipywidgets.Layout方法代碼示例

本文整理匯總了Python中ipywidgets.Layout方法的典型用法代碼示例。如果您正苦於以下問題:Python ipywidgets.Layout方法的具體用法?Python ipywidgets.Layout怎麽用?Python ipywidgets.Layout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ipywidgets的用法示例。


在下文中一共展示了ipywidgets.Layout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setDimensions

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def setDimensions(self, width=None, height=None):
        """ Set the dimensions for the map """
        def check(value, t):
            if value is None: return value
            if isinstance(value, (int, float)):
                return '{}px'.format(value)
            elif isinstance(value, (str,)):
                search = re.search('(\d+)', value).groups()
                intvalue = search[0]
                splitted = value.split(intvalue)
                units = splitted[1]
                if units == '%':
                    if t == 'width': return '{}%'.format(intvalue)
                    else: return None
                else:
                    return '{}px'.format(intvalue)
            else:
                msg = 'parameter {} of setDimensions must be int or str'
                raise ValueError(msg.format(t))
        self.layout = Layout(width=check(width, 'width'),
                             height=check(height, 'height')) 
開發者ID:fitoprincipe,項目名稱:ipygee,代碼行數:23,代碼來源:map.py

示例2: make_labels

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def make_labels():
    """Makes the labels widget.

    Returns:
        widget: The labels widget.
    """
    labels0 = widgets.HTML(value="<h5>Job ID</h5>",
                           layout=widgets.Layout(width='190px'))
    labels1 = widgets.HTML(value='<h5>Backend</h5>',
                           layout=widgets.Layout(width='145px'))
    labels2 = widgets.HTML(value='<h5>Status</h5>',
                           layout=widgets.Layout(width='95px'))
    labels3 = widgets.HTML(value='<h5>Queue</h5>',
                           layout=widgets.Layout(width='70px'))
    labels4 = widgets.HTML(value='<h5>Message</h5>')

    labels = widgets.HBox(children=[labels0, labels1, labels2, labels3, labels4],
                          layout=widgets.Layout(width='600px',
                                                margin='0px 0px 0px 37px'))
    return labels 
開發者ID:Qiskit,項目名稱:qiskit-terra,代碼行數:22,代碼來源:job_widgets.py

示例3: circuit_diagram_widget

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def circuit_diagram_widget() -> wid.Box:
    """Create a circuit diagram widget.

    Returns:
        Output widget.
    """
    # The max circuit height corresponds to a 20Q circuit with flat
    # classical register.
    top_out = wid.Output(layout=wid.Layout(width='100%',
                                           height='auto',
                                           max_height='1000px',
                                           overflow='hidden scroll',))

    top = wid.Box(children=[top_out], layout=wid.Layout(width='100%', height='auto'))

    return top 
開發者ID:Qiskit,項目名稱:qiskit-terra,代碼行數:18,代碼來源:library.py

示例4: plot

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def plot(self, show_quadrature = "", x_unit = "ns"): 
        """
        Plots the sequences stored in channel.
        A slider provides the option to sweep through different time values.
        Readout pulse is fixed at t = 0, where is t>0 before the readout tone.

        Args:
            x_unit: unit of the x-axis in the plot. Options are "s", "ms", "us", "ns".
        """
        show_iq = False
        if show_quadrature in ["I", "Q"]:
            show_iq = True
        sequences, readout_indices = self._get_sequences(IQ_mixing=show_iq)
        seq_max = len(readout_indices) - 1
        if show_quadrature is "I":
            sequences = [np.real(seq) for seq in sequences]
        elif show_quadrature is "Q":
            sequences = [np.imag(seq) for seq in sequences]
        
        bounds = self._get_boundaries(sequences, readout_indices, x_unit)
        
        interact(lambda sequence: self._plot_sequence(sequences[sequence], readout_indices[sequence], x_unit, bounds), 
                sequence = widgets.IntSlider(value = 0, min = 0, max = seq_max, layout = Layout(width = "98%", height = "50px")))
        return True 
開發者ID:qkitgroup,項目名稱:qkit,代碼行數:26,代碼來源:VirtualAWG.py

示例5: _interact_frequency

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def _interact_frequency(self,freq_val,min_freq=87.5,max_freq=108,freq_step=0.2):
        '''
        Sets up tuning frequency slider widget for Mono FM Example
        '''
        self.slider = FloatSlider(
            value=freq_val,
            min=min_freq,
            max=max_freq,
            step=freq_step,
            description=r'$f_c\;$',
            continuous_update=False,
            orientation='horizontal',
            readout_format='0.1f',
            layout=Layout(
                width='90%',
            ) 
        )
        self.slider.style.handle_color = 'lightblue'

        self.center_freq_widget = interactive(self.set_fc_mhz, fc = self.slider)
        display(self.center_freq_widget) 
開發者ID:mwickert,項目名稱:scikit-dsp-comm,代碼行數:23,代碼來源:rtlsdr_helper.py

示例6: _interact_audio_gain

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def _interact_audio_gain(self,gain_val=0,min_gain=-60,max_gain=6,gain_step=0.1):
        '''
        Sets up audio gain slider widget for Mono FM Example
        '''
        self.gain_slider = FloatSlider(
            value=gain_val,
            min=min_gain,
            max=max_gain,
            step=gain_step,
            description='Gain (dB)',
            continuous_update=True,
            orientation='horizontal',
            readout_format='0.1f',
            layout=Layout(
                width='90%',
            )
        )
        self.gain_slider.style.handle_color = 'lightgreen'

        self.audio_gain_widget = interactive(self.set_audio_gain_db,gain=self.gain_slider)
        display(self.audio_gain_widget) 
開發者ID:mwickert,項目名稱:scikit-dsp-comm,代碼行數:23,代碼來源:rtlsdr_helper.py

示例7: make_labels

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def make_labels() -> widgets.HBox:
    """Makes the labels widget.

    Returns:
        The labels widget.
    """
    labels0 = widgets.HTML(value="<h5>Job ID</h5>",
                           layout=widgets.Layout(width='190px'))
    labels1 = widgets.HTML(value='<h5>Backend</h5>',
                           layout=widgets.Layout(width='165px'))
    labels2 = widgets.HTML(value='<h5>Status</h5>',
                           layout=widgets.Layout(width='125px'))
    labels3 = widgets.HTML(value='<h5>Est. Start Time</h5>',
                           layout=widgets.Layout(width='100px'))

    labels = widgets.HBox(children=[labels0, labels1, labels2, labels3],
                          layout=widgets.Layout(width='700px',
                                                margin='0px 0px 0px 35px'))
    return labels 
開發者ID:Qiskit,項目名稱:qiskit-ibmq-provider,代碼行數:21,代碼來源:job_widgets.py

示例8: _widget

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def _widget(self):
        if not hasattr(self, "_cached_widget"):
            try:
                import ipywidgets

                children = [ipywidgets.HTML("<h2>Cluster Options</h2>")]
                children.extend([f.widget() for f in self._fields.values()])
                column = ipywidgets.Box(
                    children=children,
                    layout=ipywidgets.Layout(
                        display="flex", flex_flow="column", align_items="stretch"
                    ),
                )
                widget = ipywidgets.Box(children=[column])
            except ImportError:
                widget = None
            object.__setattr__(self, "_cached_widget", widget)
        return self._cached_widget 
開發者ID:dask,項目名稱:dask-gateway,代碼行數:20,代碼來源:options.py

示例9: widget

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def widget(self):
        import ipywidgets

        def handler(change):
            self.set(change.new)

        input = self._widget()
        input.observe(handler, "value")
        self._widgets.add(input)

        label = ipywidgets.HTML(
            "<p style='font-weight: bold; margin-right: 8px'>%s:</p>" % self.label
        )

        row = ipywidgets.Box(
            children=[label, input],
            layout=ipywidgets.Layout(
                display="flex", flex_flow="row wrap", justify_content="space-between"
            ),
        )

        return row 
開發者ID:dask,項目名稱:dask-gateway,代碼行數:24,代碼來源:options.py

示例10: __init__

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def __init__(self, pyname, getversion=False):
        self.displays = {}
        self.pyname = pyname
        self.getversion = getversion

        self.nbv_display = VBox()
        self.widgets_display = VBox()
        self.warning = ipywidgets.HTML()

        super().__init__()
        children = [ipywidgets.HTML("<h4><center>%s</center></h4>" % self.pyname,
                                    layout=ipywidgets.Layout(align_self='center')),
                    ipywidgets.HTML(self.HEADER)]

        for location in install.nbextension_ordered_paths():
            self.state = install.get_installed_versions(self.pyname, self.getversion)
            props = self._get_props(location)
            self.displays[location] = ExtensionInstallLocation(self, props)
            children.append(self.displays[location])

        children.append(self.warning)

        self.children = children
        self._highlight_active() 
開發者ID:Autodesk,項目名稱:notebook-molecular-visualization,代碼行數:26,代碼來源:visualization.py

示例11: __init__

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def __init__(self, image, client):
        self._err = False
        self._client = client
        self.image = image
        self.status = ipy.HTML(layout=ipy.Layout(width="20px"))
        self.html = ipy.HTML(value=image, layout=ipy.Layout(width="400px"))
        self.html.add_class('nbv-monospace')
        self.msg = ipy.HTML(layout=ipy.Layout(width='300px'))
        self.button = ipy.Button(layout=ipy.Layout(width='100px'))
        if mdt.compute.config.devmode:
            self.button.on_click(self.rebuild)
        else:
            self.button.on_click(self.pull)
        self._reactivate_button()
        self._set_status_value()
        super().__init__(children=[self.status, self.html, self.button, self.msg]) 
開發者ID:Autodesk,項目名稱:notebook-molecular-visualization,代碼行數:18,代碼來源:images.py

示例12: __init__

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [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') 
開發者ID:Autodesk,項目名稱:notebook-molecular-visualization,代碼行數:25,代碼來源:selection.py

示例13: __init__

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def __init__(self, format=None, *args, **kwargs):
        description = kwargs.pop('description', 'FloatSlider')
        min = kwargs.setdefault('min', 0.0)
        max = kwargs.setdefault('max', 10.0)
        self.formatstring = format
        self.header = ipy.HTML()
        self.readout = ipy.Text(layout=ipy.Layout(width='100px'))
        self.readout.on_submit(self.parse_value)

        kwargs.setdefault('readout', False)
        self.slider = ipy.FloatSlider(*args, **process_widget_kwargs(kwargs))
        self.minlabel = ipy.HTML(u'<font size=1.5>{}</font>'.format(self.formatstring.format(min)))
        self.maxlabel = ipy.HTML(u'<font size=1.5>{}</font>'.format(self.formatstring.format(max)))
        self.sliderbox = HBox([self.minlabel, self.slider, self.maxlabel])
        traitlets.link((self, 'description'), (self.header, 'value'))
        traitlets.link((self, 'value'), (self.slider, 'value'))
        self.description = description
        self.update_readout()
        super().__init__([self.header,
                                                  self.readout,
                                                  self.sliderbox]) 
開發者ID:Autodesk,項目名稱:notebook-molecular-visualization,代碼行數:23,代碼來源:components.py

示例14: __init__

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def __init__(self, value=None, units=None, **kwargs):
        kwargs.setdefault('display', 'flex')
        kwargs.setdefault('flex_flow','row wrap')
        super().__init__(layout=ipy.Layout(display='flex', flex_flow='row wrap'),
                                       **process_widget_kwargs(kwargs))
        self.textbox = ipy.Text()
        self.textbox.observe(self._validate, 'value')
        self._error_msg = None

        if units is not None:
            self.dimensionality = u.get_units(units).dimensionality
        else:
            self.dimensionality = None

        self._validated_value = None
        self.validated = ipy.HTML(self.INVALID)
        self.children = [self.textbox, self.validated]
        self._is_valid = False
        if value is not None:
            self.value = value 
開發者ID:Autodesk,項目名稱:notebook-molecular-visualization,代碼行數:22,代碼來源:components.py

示例15: __init__

# 需要導入模塊: import ipywidgets [as 別名]
# 或者: from ipywidgets import Layout [as 別名]
def __init__(self, wg_manager):
        super(WidgetPositionBase, self).__init__(wg_manager)
        self.add = widgets.Button(description=u'選定為全局資金管理策略', layout=widgets.Layout(width='98%'),
                                  button_style='info')
        # 選定全局資金管理略指令按鈕
        self.add.on_click(self.add_position)
        # 運行混入的BFSubscriberMixin中ui初始化
        self.subscriber_ui([u'點擊\'已添加的買入策略\'框中的買入策略', u'資金管理做為買入策略的資金管理策略'])
        # 買入策略框點擊行為:將本賣出策略加到對應的買入策略做為附屬
        self.buy_factors.observe(self.add_position_to_buy_factor, names='value')
        self.accordion.set_title(0, u'添加為指定買入因子的資金管理策略')
        accordion_shut(self.accordion)
        self.add_box = widgets.VBox([self.add, self.accordion])

        # 具體子策略構建
        self._init_widget() 
開發者ID:bbfamily,項目名稱:abu,代碼行數:18,代碼來源:ABuWGPosBase.py


注:本文中的ipywidgets.Layout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。