Python ipywidgets.Layout() Examples

The following are 30 code examples of ipywidgets.Layout(). 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: VirtualAWG.py    From qkit with GNU General Public License v2.0 7 votes vote down vote up
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 
Example #2
Source File: options.py    From dask-gateway with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #3
Source File: ABuWGPosBase.py    From abu with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #4
Source File: components.py    From notebook-molecular-visualization with Apache License 2.0 6 votes vote down vote up
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 
Example #5
Source File: qubit_widget.py    From scqubits with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_widget(callback_func, init_params, image_filename=None):
    """
    Displays ipywidgets for initialization of a QuantumSystem object.

    Parameters
    ----------
    callback_func: function
        callback_function depends on all the parameters provided as keys (str) in the parameter_dict, and is called upon
        changes of values inside the widgets
    init_params: {str: value, str: value, ...}
        names and values of initialization parameters
    image_filename: str, optional
        file name for circuit image to be displayed alongside the qubit
    Returns
    -------

    """
    widgets = {}
    box_list = []
    for name, value in init_params.items():
        label = ipywidgets.Label(value=name)
        if isinstance(value, float):
            enter_widget = ipywidgets.FloatText
        else:
            enter_widget = ipywidgets.IntText

        widgets[name] = enter_widget(value=value, description='', disabled=False)
        box_list.append(ipywidgets.HBox([label, widgets[name]], layout=ipywidgets.Layout(justify_content='flex-end')))

    if image_filename:
        file = open(image_filename, "rb")
        image = file.read()
        image_widget = ipywidgets.Image(value=image, format='png', layout=ipywidgets.Layout(width='400px'))
        ui_widget = ipywidgets.HBox([ipywidgets.VBox(box_list), ipywidgets.VBox([image_widget])])
    else:
        ui_widget = ipywidgets.VBox(box_list)

    out = ipywidgets.interactive_output(callback_func, widgets)
    display(ui_widget, out) 
Example #6
Source File: job_widgets.py    From qiskit-terra with Apache License 2.0 6 votes vote down vote up
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 
Example #7
Source File: components.py    From notebook-molecular-visualization with Apache License 2.0 6 votes vote down vote up
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]) 
Example #8
Source File: library.py    From qiskit-terra with Apache License 2.0 6 votes vote down vote up
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 
Example #9
Source File: selection.py    From notebook-molecular-visualization with Apache License 2.0 6 votes vote down vote up
def __init__(self, mol):
        super().__init__(mol)

        self.selection_type = ipy.Dropdown(description='Clicks select:',
                                           value=self.viewer.selection_type,
                                           options=('Atom', 'Residue', 'Chain'))

        traitlets.link((self.selection_type, 'value'), (self.viewer, 'selection_type'))

        self.residue_listname = ipy.Label('Selected residues:', layout=ipy.Layout(width='100%'))
        self.residue_list = ipy.SelectMultiple(options=list(), height='150px')
        self.viewer.observe(self._update_reslist, 'selected_atom_indices')

        self.residue_list.observe(self.remove_atomlist_highlight, 'value')
        self.atom_list.observe(self.remove_reslist_highlight, 'value')

        self.subtools.children = [self.representation_buttons]
        self.subtools.layout.flex_flow = 'column'
        self.toolpane.children = [self.selection_type,
                                  HBox([self.select_all_atoms_button, self.select_none]),
                                  self.atom_listname,
                                  self.atom_list,
                                  self.residue_listname,
                                  self.residue_list] 
Example #10
Source File: selection.py    From notebook-molecular-visualization with Apache License 2.0 6 votes vote down vote up
def __init__(self, mol):
        super().__init__(mol)

        self._bondset = collections.OrderedDict()
        self._drawn_bond_state = set()

        self.bond_listname = ipy.Label('Selected bonds:', layout=ipy.Layout(width='100%'))
        self.bond_list = ipy.SelectMultiple(options=list(),
                                            layout=ipy.Layout(height='150px'))
        self.viewer.observe(self._update_bondlist, 'selected_atom_indices')

        self.atom_list.observe(self.remove_bondlist_highlight, 'value')

        self.subtools.children = [HBox([self.select_all_atoms_button,
                                        self.select_none])]
        self.toolpane.children = (self.atom_listname,
                                  self.atom_list,
                                  self.bond_listname,
                                  self.bond_list) 
Example #11
Source File: rtlsdr_helper.py    From scikit-dsp-comm with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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) 
Example #12
Source File: rtlsdr_helper.py    From scikit-dsp-comm with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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) 
Example #13
Source File: images.py    From notebook-molecular-visualization with Apache License 2.0 6 votes vote down vote up
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]) 
Example #14
Source File: visualization.py    From notebook-molecular-visualization with Apache License 2.0 6 votes vote down vote up
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() 
Example #15
Source File: job_widgets.py    From qiskit-ibmq-provider with Apache License 2.0 6 votes vote down vote up
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 
Example #16
Source File: options.py    From dask-gateway with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #17
Source File: map.py    From ipygee with MIT License 6 votes vote down vote up
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')) 
Example #18
Source File: selection.py    From notebook-molecular-visualization with Apache License 2.0 6 votes vote down vote up
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 #19
Source File: docker.py    From notebook-molecular-visualization with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        self.client = None
        self.warning = ipy.HTML(description='<b>Engine status:</b>', value=SPINNER)
        self.devmode_label = ipy.Label('Use local docker images (developer mode)',
                                       layout=ipy.Layout(width='100%'))
        self.devmode_button = ipy.Checkbox(value=mdt.compute.config.devmode,
                                           layout=ipy.Layout(width='15px'))
        self.devmode_button.observe(self.set_devmode, 'value')

        self.engine_config_description = ipy.HTML('Docker host with protocol and port'
                                                  ' (e.g., <code>http://localhost:2375</code>).'
                                                  ' If blank, this'
                                                  ' defaults to the docker engine configured at '
                                                  'your command line.',
                                                  layout=ipy.Layout(width='100%'))
        self.engine_config_value = ipy.Text('blank', layout=ipy.Layout(width='100%'))
        self.engine_config_value.add_class('nbv-monospace')

        self.image_box = ipy.Box()

        self._reset_config_button = ipy.Button(description='Reset',
                                               tooltip='Reset to applied value')
        self._apply_changes_button = ipy.Button(description='Apply',
                                                tooltip='Apply for this session')
        self._save_changes_button = ipy.Button(description='Make default',
                                               tooltip='Make this the default for new sessions')
        self._reset_config_button.on_click(self.reset_config)
        self._apply_changes_button.on_click(self.apply_config)
        self._save_changes_button.on_click(self.save_config)

        self.children = [self.warning,
                         VBox([self.engine_config_description,
                               self.engine_config_value]),
                         HBox([self._reset_config_button,
                               self._apply_changes_button,
                               self._save_changes_button]),
                         HBox([self.devmode_button, self.devmode_label]),
                         self.image_box]
        self.reset_config()
        super().__init__(children=self.children)
        self.connect_to_engine() 
Example #20
Source File: interfaces.py    From notebook-molecular-visualization with Apache License 2.0 5 votes vote down vote up
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">&nbsp;</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 #21
Source File: progress.py    From pywr with GNU General Public License v3.0 5 votes vote down vote up
def reset(self):
        from ipywidgets import FloatProgress, HBox, Label, Layout
        from IPython.display import display
        super(JupyterProgressRecorder, self).reset()
        self.progress_bar = FloatProgress(min=0, max=100, description='Running:')
        self.label = Label("", layout=Layout(width='100%'))
        self.box = HBox([self.progress_bar, self.label])
        display(self.box) 
Example #22
Source File: compute.py    From notebook-molecular-visualization with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        from pip._vendor.packaging import version

        super().__init__()

        self.version = ipy.HTML('<div class="nbv-loader"></div>')
        self.textarea = ipy.Textarea(layout=ipy.Layout(width='700px', height='300px'))
        threading.Thread(target=self.version_check).start()

        p1 = os.path.join(mdt.PACKAGEPATH, "HISTORY.rst")
        p2 = os.path.join(mdt.PACKAGEPATH, "..", "HISTORY.rst")
        if os.path.exists(p1):
            path = p1
        elif os.path.exists(p2):
            path = p2
        else:
            path = None

        if path is not None:
            with open(path, 'r') as infile:
                self.textarea.value = infile.read()
        else:
            self.textarea.value = 'HISTORY.rst not found'

        self.textarea.disabled = True
        self.children = (self.version, self.textarea) 
Example #23
Source File: notebook_integration.py    From adaptive with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def live_info(runner, *, update_interval=0.5):
    """Display live information about the runner.

    Returns an interactive ipywidget that can be
    visualized in a Jupyter notebook.
    """
    if not _holoviews_enabled:
        raise RuntimeError(
            "Live plotting is not enabled; did you run "
            "'adaptive.notebook_extension()'?"
        )

    import ipywidgets
    from IPython.display import display

    status = ipywidgets.HTML(value=_info_html(runner))

    cancel = ipywidgets.Button(
        description="cancel runner", layout=ipywidgets.Layout(width="100px")
    )
    cancel.on_click(lambda _: runner.cancel())

    async def update():
        while not runner.task.done():
            await asyncio.sleep(update_interval)

            if should_update(status):
                status.value = _info_html(runner)
            else:
                await asyncio.sleep(0.05)

        status.value = _info_html(runner)
        cancel.layout.display = "none"

    runner.ioloop.create_task(update())

    display(ipywidgets.VBox((status, cancel))) 
Example #24
Source File: ABuWGUmp.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def _init_train_ui(self):
        """裁判特征训练面初始化"""
        description = widgets.Textarea(
            value=u'裁判特征训练:\n'
                  u'通过在\'裁判特征采集\'选中\'回测过程生成交易特征\'可在回测完成后保存当此回测结果\n'
                  u'所有回测的结果将显示在下面的\'备选回测:\'框中\n'
                  u'通过\'开始训练裁判\'进行指定的回测裁判训练,训练后的裁判在\'裁判预测拦截\'下可进行选择,选中的裁判将在对应的'
                  u'回测中生效,即开始在回测中对交易进行预测拦截等智能交易干涉行为',

            disabled=False,
            layout=widgets.Layout(height='150px')
        )

        self.abu_result = widgets.Select(
            options=[],
            description=u'备选回测:',
            disabled=False,
            layout=widgets.Layout(width='100%', align_items='stretch')
        )
        self.load_abu_result()

        train_bt = widgets.Button(description=u'开始训练裁判', layout=widgets.Layout(width='98%'),
                                  button_style='info')
        train_bt.on_click(self._do_train)
        delete_bt = widgets.Button(description=u'删除选择的备选回测本地数据', layout=widgets.Layout(width='98%'),
                                   button_style='warning')
        delete_bt.on_click(self._do_delete_abu_result)

        return widgets.VBox([description, self.abu_result, train_bt, delete_bt]) 
Example #25
Source File: images.py    From notebook-molecular-visualization with Apache License 2.0 5 votes vote down vote up
def __init__(self, client):
        self.client = client

        images = self._get_images()
        self.header = ipy.HTML(
                '<span class="nbv-table-header" style="width:950px"">Image status</span>',
                layout=ipy.Layout(align_items='flex-end'))
        super().__init__([self.header] + [DockerImageView(im, client) for im in sorted(images)]) 
Example #26
Source File: ABuWGSFBase.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, wg_manager):
        super(WidgetFactorSellBase, self).__init__(wg_manager)

        if wg_manager.add_button_style == 'grid':
            add_cb = widgets.Button(description=u'添加为寻找卖出策略最优参数组合', layout=widgets.Layout(width='98%'),
                                    button_style='info')
            add_cb.on_click(self.add_sell_factor)

            add_dp = widgets.Button(description=u'添加为寻找独立卖出策略最佳组合', layout=widgets.Layout(width='98%'),
                                    button_style='warning')
            add_dp.on_click(self.add_sell_factor_grid)

            self.add = widgets.VBox([add_cb, add_dp])
        else:
            self.add = widgets.Button(description=u'添加为全局卖出策略', layout=widgets.Layout(width='98%'),
                                      button_style='info')
            # 添加全局卖出策略指令按钮
            self.add.on_click(self.add_sell_factor)

        if self.wg_manager.show_add_buy:
            # 运行混入的BFSubscriberMixin中ui初始化
            self.subscriber_ui([u'点击\'已添加的买入策略\'框中的买入策略', u'将卖出策略做为买入策略的附属卖出策略'])
            # 买入策略框点击行为:将本卖出策略加到对应的买入策略做为附属
            self.buy_factors.observe(self.add_sell_factor_to_buy_factor, names='value')
            self.accordion.set_title(0, u'添加为指定买入因子的卖出策略')
            accordion_shut(self.accordion)
            self.add_box = widgets.VBox([self.add, self.accordion])
        else:
            self.add_box = self.add

        self._init_widget() 
Example #27
Source File: widget_utils.py    From notebook-molecular-visualization with Apache License 2.0 5 votes vote down vote up
def process_widget_kwargs(kwargs):
    from ipywidgets import Layout

    layout = kwargs.get('layout', None)

    for arg in list(kwargs.keys()):
        if arg in LAYOUT_PROPS:
            if not layout:
                layout = Layout()
            setattr(layout, arg, kwargs.pop(arg))

    if layout is not None:
        kwargs['layout'] = layout

    return kwargs 
Example #28
Source File: utils.py    From notebook-molecular-visualization with Apache License 2.0 5 votes vote down vote up
def make_layout(layout=None, **kwargs):
    from ipywidgets import Layout
    import traitlets

    if layout is None:
        layout = Layout()
    for key, val in kwargs.items():
        # note that this is the type of the class descriptor, not the instance attribute
        if isinstance(getattr(Layout, key), traitlets.Unicode):
            val = in_pixels(val)
        setattr(layout, key, val)
    return layout 
Example #29
Source File: ABuWGUmp.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def _init_feature_ui(self):
        """裁判特征采集界面初始化"""
        ml_feature_description = widgets.Textarea(
            value=u'裁判特征采集\n'
                  u'裁判是建立在机器学习技术基础上的,所以必然会涉及到特征,abu量化系统支持在回测过程中生成特征数据,切分训练测试集,'
                  u'甚至成交买单快照图片,通过打开下面的开关即可在生成最终的输出结果数据订单信息上加上买入时刻的很多信息,'
                  u'比如价格位置、趋势走向、波动情况等等特征, 注意需要生成特征后回测速度效率会降低\n'
                  u'如在下拉选择中选中\'回测过程生成交易特征\'在回测完成后将保存回测结果,通过在\'裁判特征训练\'可进行查看并进行'
                  u'裁判训练',
            disabled=False,
            layout=widgets.Layout(height='150px')
        )

        self.enable_ml_feature = widgets.Dropdown(
            options={u'回测过程不生成交易特征': 0,
                     u'回测过程生成交易特征': 1},
            value=0,
            description=u'特征生成:',
        )
        return widgets.VBox([ml_feature_description, self.enable_ml_feature]) 
Example #30
Source File: ABuWGUmp.py    From abu with GNU General Public License v3.0 5 votes vote down vote up
def _init_manager_ui(self):
        """裁判数据管理界面初始化"""
        description = widgets.Textarea(
            value=u'删除选择的裁判本地数据:\n'
                  u'删除所选择的已训练好的本地裁判数据,谨慎操作!\n'
                  u'分享选择的裁判:\n'
                  u'将训练好的裁判数据分享到交易社区,供其他交易者使用\n'
                  u'下载更多的裁判:\n'
                  u'从交易社区,下载更多训练好的裁判数据\n',

            disabled=False,
            layout=widgets.Layout(height='150px')
        )

        self.manager_umps = widgets.Select(
            options=[],
            description=u'本地裁判:',
            disabled=False,
            layout=widgets.Layout(width='100%', align_items='stretch')
        )
        self.load_train_ump(self.manager_umps)
        delete_bt = widgets.Button(description=u'删除选择的裁判本地数据', layout=widgets.Layout(width='98%'),
                                   button_style='warning')
        delete_bt.on_click(self._do_delete_ump)

        share_bt = widgets.Button(description=u'分享选择的裁判', layout=widgets.Layout(width='98%'),
                                  button_style='info')
        share_bt.on_click(permission_denied)
        down_bt = widgets.Button(description=u'下载更多的裁判', layout=widgets.Layout(width='98%'),
                                 button_style='info')
        down_bt.on_click(permission_denied)

        return widgets.VBox([description, self.manager_umps, delete_bt, share_bt, down_bt])