Example #1
0
    def __init__(self, root_dir: path = None):
        self.root_dir: path = root_dir
        if self.root_dir is None:
            self.root_dir = path.join(path.sep, 'p', 'fastdata', 'slmet',
                                      'slmet111', 'met_data', 'ecmwf', 'era5',
                                      'nc')

        # filers and filter (multiple selection widget)
        self.dataset_files_selection: widgets.SelectMultiple = widgets.SelectMultiple(
        )
        self.filter_selection: widgets.SelectMultiple = widgets.SelectMultiple(
        )
        self.filter_specification_box: FilterBox = FilterBox()
        self.filter_specification: widgets.Box = widgets.Box([])

        self.datasets: List[DatasetFile] = []
        self.dataset_filters: List[DatasetFileFilter] = []

        self.recently_removed_datasets: List[List[DatasetFile]] = [[]]

        self.datebox_main: DateSelector = DateSelector()

        button_collect: widgets.Button = widgets.Button(
            description='Collect Datasets',
            disabled=False,
            button_style='success',
            # 'success', 'info', 'warning', 'danger' or ''
            tooltip='Collects datasets within the given time interval',
            # icon='fa-bomb',
            style=style)

        def button_collect_clicked(collect_button: widgets.Button):
            self.datasets = []
            # check if dates are valid
            if self.datebox_main.evaluate_dates():
                # collect available datasets from specified start and end datetime objects
                if self.collect_datasets(
                        date_start=self.datebox_main.get_start_date(),
                        date_end=self.datebox_main.get_end_date()):
                    # if any datasets were found, initialize further widgets for filtering of selected files
                    self.init_dataset_specification()
                else:
                    notify('No datasets were found from ' +
                           str(self.datebox_main.get_start_date()) + ' to ' +
                           str(self.datebox_main.get_end_date()))

        button_collect.on_click(button_collect_clicked)

        self.date_selection_box: widgets.VBox = widgets.VBox(
            [self.datebox_main, button_collect],
            layout=widgets.Layout(display='flex',
                                  flex_flow='row wrap',
                                  justify_content='space-around',
                                  align_items='center'))
        self.dataset_specification_box: widgets.Box = widgets.Box()

        self.main_component: widgets.Accordion = widgets.Accordion(
            children=[self.date_selection_box])
        self.main_component.set_title(0, 'Selection Interval')
        self.main_component.selected_index = 0
Example #2
0
 def __init__(self, data_collection=None, session=None):
     super(JupyterApplication,
           self).__init__(data_collection=data_collection, session=session)
     self.selection_modes = [('replace', ReplaceMode), ('add', OrMode),
                             ('and', AndMode), ('xor', XorMode),
                             ('remove', AndNotMode)]
     self.widget_selection_mode = widgets.ToggleButtons(
         options=[label for label, mode in self.selection_modes],
         description='Selection mode:',
         disabled=False,
         tooltips=[label for label, mode in self.selection_modes],
     )
     self.widget_data_collection = widgets.SelectMultiple()
     self.widget_subset_groups = widgets.SelectMultiple()
     self.widget = widgets.VBox(
         children=[self.widget_selection_mode, self.widget_subset_groups])
     self.widget_selection_mode.observe(self._set_selection_mode, 'index')
     self.widget_subset_groups.observe(self._set_subset_groups, 'index')
     self.session.hub.subscribe(self,
                                msg.EditSubsetMessage,
                                handler=self._on_edit_subset_msg)
     self.session.hub.subscribe(self,
                                msg.SubsetCreateMessage,
                                handler=self._on_subset_create_msg)
     self._update_subset_mode(self.session.edit_subset_mode.mode)
     self._update_subset_groups_selected(
         self.session.edit_subset_mode.edit_subset)
     display(self.widget)
Example #3
0
def Ex2Chapitre1_7():
    """Provides the correction to exercise 2 of notebook 1_7
    """

    print("Cliquer sur CTRL pour sélectionner plusieurs réponses")

    style = {'description_width': 'initial'}
    inc = widgets.SelectMultiple(
        options=['a)', 'b)', 'c)', 'd)'],
        description='Incompatibles:',
        style=style,
        layout=Layout(width='15%', height='90px'),
        disabled=False,
    )
    comp = widgets.SelectMultiple(options=['a)', 'b)', 'c)', 'd)'],
                                  description='Compatibles:',
                                  layout=Layout(width='15%', height='90px'),
                                  disabled=False)

    def correction(inc, c):
        if 'a)' in c and 'c)' in c and 'd)' in c and 'b)' in inc:
            print("C'est correct!")
            print(
                "En particulier, les systèmes a) et d) admettent une infinité de solutions, tandis que le système c) "
                "admet une solution unique.")
        else:
            print("C'est faux. Veuillez rentrer d'autres valeurs")

    interact_manual(correction, inc=inc, c=comp)

    return
 def __init__(self):
     genes = self.get_genes()
     timepoints = self.get_timepoints()
     genotypes = self.get_genotypes()
     self.select_gene = sg = widgets.Select(
         options=genes,
         value=genes[0],
         description="genes",
         disabled=False
     )
     self.select_timepoints = st = widgets.SelectMultiple(
         options=timepoints,
         value=timepoints[:1],
         description="time points",
         disabled=False
     )
     self.select_genotypes = sgt = widgets.SelectMultiple(
         options=genotypes,
         value=genotypes[:1],
         description="genotypes",
         disabled=False
     )
     showbutton = self.show_button = widgets.Button(description="show")
     showbutton.on_click(self.show_click)
     self.assembly = widgets.HBox(children=(sg, st, sgt, showbutton))
     display(self.assembly)
Example #5
0
    def __init__(
        self,
        df,
        group_keys=None,
        filter_key=None,
        filter_values=None,
        method='max',
        plot_type='bar',
        output_file=None,
        transpose=True,
    ):
        self.df = df
        self.filtered_df = df

        index_names = sorted(df.index.names)

        self.w_parameters = widgets.SelectMultiple(
            options=index_names,
            value=group_keys if group_keys is not None else [index_names[0]],
            description='Group By',
        )
        valid_methods = ['min', 'max', 'mean', 'box']
        self.w_method = widgets.RadioButtons(
            options=valid_methods,
            value=method if method in valid_methods else 'max')
        self.w_method.observe(self.update_available_plot_types)

        valid_plot_types = ['line', 'bar']
        self.w_plot_type = widgets.RadioButtons(
            options=valid_plot_types,
            value=plot_type if plot_type in valid_plot_types else 'bar',
        )

        self.w_transpose = widgets.Checkbox(description='transpose',
                                            value=transpose)
        self.w_filter_key = widgets.Select(
            options=[''] + index_names[:],
            description='Filter field',
            value=filter_key if filter_key is not None else '',
        )
        self.w_filter_value = widgets.SelectMultiple(
            options=[], description='Filter value')
        self.update_possible_filter_values(None)
        if filter_values is not None:
            self.w_filter_value.value = filter_values

        self.w_file_name = widgets.Text(
            value=output_file if output_file is not None else '',
            description='output CSV Path',
        )
        self.w_overwrite = widgets.Checkbox(
            description='allows overwriting output files')
        self.w_output_button = widgets.Button(description='Generate CSV')
        self.w_export_output = widgets.Output()

        self.w_filter_key.observe(self.update_possible_filter_values)
        self.w_output_button.on_click(self.csv_callback)
        self.display()
Example #6
0
def basic_buttons(hdbdata):
    """
    Creates a widget box containing basic buttons to filter HDB results
    """
    # https://blog.jupyter.org/introducing-templates-for-jupyter-widget-layouts-f72bcb35a662
    # https://github.com/jupyter-widgets/ipywidgets/issues/1853#issuecomment-349201240
    # Configure layout and set up widgets for plotly
    filterdict = {
        'flat_model':
        widgets.SelectMultiple(options=hdbdata['flat_model'].unique(),
                               value=list(hdbdata['flat_model'].unique()),
                               description='Flat Model'),
        'flat_type':
        widgets.SelectMultiple(options=hdbdata['flat_type'].unique(),
                               value=list(hdbdata['flat_type'].unique()),
                               description='Flat Type'),
        'storey_range':
        widgets.SelectMultiple(options=hdbdata['storey_range'].unique(),
                               value=list(hdbdata['storey_range'].unique()),
                               description='Storeys'),
        'floor_area_sqm':
        widgets.FloatRangeSlider(value=[
            hdbdata['floor_area_sqm'].min(), hdbdata['floor_area_sqm'].max()
        ],
                                 min=hdbdata['floor_area_sqm'].min(),
                                 max=hdbdata['floor_area_sqm'].max(),
                                 step=1,
                                 description='Floor Area (sqm):',
                                 layout=Layout(width='100%')),
        'remaining_lease':
        widgets.FloatRangeSlider(value=[
            hdbdata['remaining_lease'].min(), hdbdata['remaining_lease'].max()
        ],
                                 min=hdbdata['remaining_lease'].min(),
                                 max=hdbdata['remaining_lease'].max(),
                                 step=1,
                                 description='Remaining Lease (years):',
                                 layout=Layout(width='100%')),
        'month':
        widgets.SelectionRangeSlider(
            options=[(i, i) for i in hdbdata['month'].unique()],
            index=(0, hdbdata['month'].unique().size - 1),
            description='Date of transaction',
            layout=Layout(width='100%'))
    }
    h1 = HBox([
        filterdict['flat_model'], filterdict['flat_type'],
        filterdict['storey_range']
    ])
    h2 = filterdict['floor_area_sqm']
    h3 = filterdict['remaining_lease']
    h4 = filterdict['month']
    filter_widget = VBox([h1, h2, h3, h4])
    return filterdict, filter_widget
Example #7
0
    def _init_filter_ctrls(self):
        """Initialize the filter controls."""
        # text_filter
        self.widgets["filter_text"] = widgets.Text(
            description="Filter",
            layout=self.layouts["layout_norm"],
            style=self.w_style)
        self.widgets["filter_text"].continuous_update = False
        self.widgets["filter_text"].observe(self._update_select_list, "value")
        self.widgets["filter_help"] = widgets.Label(
            value=" comma ORs values, '+' ANDs values")

        # Mitre filters
        self.widgets["sel_techniques"] = widgets.SelectMultiple(
            description="Mitre Techniques",
            options=self._get_mitre_filter_options(
                self.mordor_driver.mdr_idx_tech,
                self.mordor_driver.mitre_techniques),
            layout=self.layouts["mitre_select_layout"],
            style=self.w_style,
        )

        self.widgets["sel_tactics"] = widgets.SelectMultiple(
            description="Mitre Tactics",
            options=self._get_mitre_filter_options(
                self.mordor_driver.mdr_idx_tact,
                self.mordor_driver.mitre_tactics),
            layout=self.layouts["mitre_select_layout"],
            style=self.w_style,
        )
        self._reset_filters()
        self.widgets["sel_techniques"].observe(self._update_select_list,
                                               names="value")
        self.widgets["sel_tactics"].observe(self._update_select_list,
                                            names="value")

        self.widgets["filter_reset"] = widgets.Button(
            description="Reset filter")
        self.widgets["filter_reset"].on_click(self._reset_filters)
        wgt_filter_grp = widgets.VBox([
            widgets.HBox(
                [self.widgets["filter_text"], self.widgets["filter_help"]]),
            widgets.HBox([
                self.widgets["sel_techniques"],
                self.widgets["sel_tactics"],
                self.widgets["filter_reset"],
            ]),
        ])
        self.widgets["filter_grp"] = widgets.Accordion(
            children=[wgt_filter_grp])
        self.widgets["filter_grp"].set_title(0, "Filters")
        self.widgets["filter_grp"].selected_index = None
Example #8
0
 def __init__(self, ml_repo, beakerX=False):
     self._ml_repo = ml_repo
     self._categories = widgets.SelectMultiple(
         options=[k.value for k in MLObjectType])
     self._repo_info = widgets.SelectMultiple(
         options=[k.value for k in RepoInfoKey], value=['category', 'name'])
     self._button_update = widgets.Button(description='update')
     self._button_update.on_click(self.get_overview)
     self._output = widgets.Output()
     self._input_box = widgets.HBox(children=[
         widgets.VBox(children=[self._categories, self._repo_info]),
         self._button_update, self._output
     ])
Example #9
0
    def plotDetailStat(self):
        selectCategory = widgets.SelectMultiple(
            options=self.cat_dictionary.tolist(),
            value=[self.cat_dictionary[0]],
            description='Category')

        dropdownQuantity = widgets.Dropdown(
            options=[self.cquant1, self.cquant2, self.cquant3],
            value=self.cquant1,
            description='Quantity Column')

        selectCustomViz = widgets.SelectMultiple(
            options=['Mean', 'Min', 'Max', '1-SD', 'Sum'],
            value=['Mean', '1-SD'],
            description='Show')

        # print color_map
        allcmap = plt.colormaps()

        cmapArr = []
        for cmap in allcmap:
            if '_r' not in cmap:
                cmapArr.append(cmap)

        dropdownNames = widgets.Dropdown(options=self.names_list,
                                         value='All Names',
                                         description='Names')

        dropdownCmap = widgets.Dropdown(options=cmapArr,
                                        value='viridis',
                                        description='Color')

        sliderBin = widgets.IntSlider(value=12,
                                      min=1,
                                      max=80,
                                      step=1,
                                      description='Date Binning:',
                                      orientation='horizontal',
                                      readout=True,
                                      readout_format='i',
                                      slider_color='white')

        widgets.interact(self.show_quantity,
                         name=dropdownNames,
                         categories=selectCategory,
                         quant=dropdownQuantity,
                         shows=selectCustomViz,
                         binNumber=sliderBin,
                         color=dropdownCmap)
Example #10
0
    def __init__(self):
        """构建股票池选股ui界面"""
        label_layout = widgets.Layout(width='300px', align_items='stretch', justify_content='space-between')
        self.cs_tip = widgets.Label(value=u'如果股池为空,回测将使用大盘市场中所有股票', layout=label_layout)
        # 股票池多选框
        self.choice_symbols = widgets.SelectMultiple(
            description=u'股池:',
            disabled=False,
            layout=widgets.Layout(width='300px', align_items='stretch', justify_content='space-between')
        )
        self.choice_symbols.observe(self.choice_symbols_select, names='value')

        # 构建所有沙盒中的数据序列
        market_title = [u'台股']
        tw_seed_symbol = [to_unicode('{}:{}'.format(AbuSymbolTW()[symbol].co_name.values[0], symbol))
                          for symbol in ABuMarket.K_SAND_BOX_TW]
        # 沙盒中的数据序列构建数据字典
        self.market_dict = {u'台股': tw_seed_symbol}

        # 一个市场一个tab,tab中的symbol为沙盒中的symbol
        self.market_widget_tab = widgets.Tab()
        self.market_symbol_widget = []
        for title in market_title:
            market_symbol = widgets.SelectMultiple(
                options=self.market_dict[title],
                description=title,
                disabled=False
            )
            market_symbol.observe(self.on_already_select, names='value')
            self.market_symbol_widget.append(market_symbol)
        self.market_widget_tab.children = self.market_symbol_widget
        for ind, name in enumerate(market_title):
            self.market_widget_tab.set_title(ind, name)

        self.sc_box = WidgetSearchBox(self.on_already_select)()

        # 下拉选择标尺大盘
        self.market = widgets.Dropdown(
            options={u'台股': EMarketTargetType.E_MARKET_TARGET_TW.value},
            value=ABuEnv.g_market_target.value,
            description=u'大盘市场:',
        )
        self.market.observe(self.on_market_change, names='value')

        market_tip = widgets.Label(value=u'大盘市场设置只影响收益对比标尺', layout=label_layout)
        market_box = widgets.VBox([self.market, market_tip])

        self.widget = widgets.VBox([self.cs_tip, self.choice_symbols, self.market_widget_tab,
                                    self.sc_box, market_box])
Example #11
0
    def single_image_view_specifier(self, imgId):
        gt_segs, pd_segs = self.gt.img2seg[imgId], self.pd.img2seg[imgId]
        _gt_cats = {seg['category_id'] for seg in gt_segs.values()}
        _pd_cats = {seg['category_id'] for seg in pd_segs.values()}
        relevant_catIds = _gt_cats | _pd_cats
        tranche_map = self._tranche_filter(gt_segs, pd_segs)
        modes = ['bulk', 'walk']

        def logic(catIds, tranches, mode):
            # only for walk, not for bulk display
            seg_list = self._cat_filter_and_merge_tranche_map(
                tranche_map, catIds, tranches)
            if mode == modes[0]:
                self.single_image_bulk_display(seg_list)
            elif mode == modes[1]:
                self.walk_primary(seg_list)

        UI = interactive(logic,
                         mode=widgets.ToggleButtons(options=modes,
                                                    value=modes[0]),
                         catIds=self._category_roulette(
                             relevant_catIds,
                             multi_select=True,
                             default_cid=[self.global_state['catId']]),
                         tranches=widgets.SelectMultiple(
                             options=tranche_map.keys(),
                             value=[self.global_state['tranche']]))
        ipy_display(UI)
Example #12
0
 def createSelectWidget(self):
     entries = self.getEntries()
     self._entries = entries = [
         ' .',
         ' ..',
     ] + entries
     if self.multiple:
         value = []
         self.select = ipyw.SelectMultiple(
             value=value,
             options=entries,
             description="Select",
             layout=self.select_multiple_layout)
     else:
         value = entries[0]
         self.select = ipyw.Select(value=value,
                                   options=entries,
                                   description="Select",
                                   layout=self.select_layout)
     """When ipywidgets 7.0 is released, the old way that the select or select multiple 
        widget was set up (see below) should work so long as self.select_layout is changed
        to include the display="flex" and flex_flow="column" statements. In ipywidgets 6.0,
        this doesn't work because the styles of the select and select multiple widgets are
        not the same.
     
     self.select = widget(
         value=value, options=entries,
         description="Select",
         layout=self.select_layout) """
     return self.select
Example #13
0
    def __init__(self, options, *args, **kwargs):
        """Created a Multi-select widget

        Parameters
        ----------
        options : Sequence[str]
            The options to show in the multi-select widget.
        """

        super().__init__([])

        self.options = [str(option) for option in options]
        self.multi_select = widgets.SelectMultiple(
            options=self.options, description="Label:"
        )
        widgets.link((self, "options"), (self.multi_select, "options"))
        widgets.link((self, "value"), (self.multi_select, "value"))

        self.hints = defaultdict(widgets.Output)

        self.children = [
            self.multi_select,
            widgets.HBox(
                children=[self.hints[option] for option in self.value],
                layout=widgets.Layout(flex_flow="row wrap"),
            ),
        ]
Example #14
0
    def __init__(self, data_collection=None, session=None, settings=None):

        super(JupyterApplication,
              self).__init__(data_collection=data_collection, session=session)

        try:
            from glue.main import load_plugins
            load_plugins()
        except Exception:  # Compatibility with glue <0.16
            from glue.main import REQUIRED_PLUGINS
            REQUIRED_PLUGINS.clear()
            load_plugins()

        self.output = widgets.Output()
        self.widget_data_collection = widgets.SelectMultiple()
        self.widget_subset_select = SubsetSelect(session=self.session)
        self.widget_subset_mode = SelectionModeMenu(session=self.session)
        self.widget = widgets.VBox(
            children=[self.widget_subset_mode, self.output])

        self._settings['new_subset_on_selection_tool_change'] = [
            False, is_bool
        ]

        if settings is not None:
            for key, value in settings.items():
                self.set_setting(key, value)

        self._viewer_refs = []
 def select_multiple_tables(anomaly_lookup):
     table_list = anomaly_lookup.query_table_list()
     tables = sorted(table_list.TableName.tolist())
     return widgets.SelectMultiple(options=tables,
                                   row=len(tables),
                                   value=[],
                                   description='Tables:')
def select_mult_parameters(things: set, description=""):
    height = len(things) * 19
    return widgets.SelectMultiple(options=things,
                                  description=description,
                                  disabled=False,
                                  layout=widgets.Layout(height=f"{height}px",
                                                        width='175px'))
Example #17
0
    def __init__(self, search_result_callable):
        """构建股票池选股ui界面"""
        if not callable(search_result_callable):
            raise TypeError('search_result_select_func must callable!')
        # symbol搜索框构建
        self.search_bt = widgets.Button(description=u'搜索:', layout=widgets.Layout(height='10%', width='7%'))
        self.search_input = widgets.Text(
            value='',
            placeholder=u'交易代码/公司名称/拼音首字母',
            description='',
            disabled=False
        )
        self.search_input.observe(self._search_input_change, names='value')

        # symbol搜索结果框
        self.search_result = widgets.SelectMultiple(
            options=[],
            description=u'搜索结果:',
            disabled=False,
            layout=widgets.Layout(width='300px', align_items='stretch', justify_content='space-between')
        )
        self.search_result.observe(search_result_callable, names='value')
        self.search_bt.on_click(self._do_search)

        # 搜索框 + 按钮 + 结果框 box拼接
        sc_hb = widgets.HBox([self.search_bt, self.search_input])
        self.widget = widgets.VBox([sc_hb, self.search_result])
Example #18
0
def create_usage_widgets(content_type_callback, usage_type_callback,
                         extra_buttons):
    """Create widgets used for visualizing content usage."""
    comparison_selector = ipywidgets.SelectMultiple(
        options=cfg.NODES,
        selected_labels=["Physics", "Biology", "Chemistry"],
        width="200px")
    comparison_selector.height = '270px'
    type_selector1 = widgets.create_toggle(["all", "videos", "exercises"],
                                           content_type_callback)
    type_selector2 = widgets.create_toggle(
        ["articles", "talkthroughs", "scratchpads"], content_type_callback)
    plot_selector = widgets.create_toggle(
        ["Learners", "Learning Time", "Content Nodes Learned"],
        usage_type_callback,
        style="primary",
        button_width="300px",
        orientation="vertical")
    title = ipywidgets.HTML(
        value='<div class=VizTitle><h2> Content Usage </h2> </div>')
    toggle_container = ipywidgets.VBox(children=[
        title, widgets.gap, type_selector1, type_selector2, widgets.gap,
        plot_selector
    ],
                                       width="300px")
    extras = [
        ipywidgets.HTML(value='<div class=VizTitle><h4> Extras: </h4> </div>')
    ]
    extras.extend(extra_buttons)
    extra_container = ipywidgets.VBox(extras, width="200px")
    usage_container = ipywidgets.HBox(
        children=[toggle_container, comparison_selector, extra_container])
    return usage_container, comparison_selector
Example #19
0
def select_area(raster):

    # Get the list of IDs from the raster, use it for the dropdown field
    raster_np = pcraster.pcr2numpy(raster, -9999)

    raster_values = numpy.unique(raster_np)

    raster_unique = numpy.unique(raster_values)

    sections = numpy.delete(raster_unique, numpy.where(raster_unique == -9999))

    hover = HoverTool(tooltips=[
        ("Floodplain section", "@image"),
    ])
    p = plot(raster, hover=hover)

    display(p)

    style = {'description_width': 'initial'}
    w = ipywidgets.SelectMultiple(options=sections,
                                  rows=8,
                                  description='Sections:',
                                  layout=Layout(width="50%"),
                                  style=style,
                                  disabled=False)

    display(w)
    return w
Example #20
0
    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 #21
0
def create_production_widgets(content_type_callback, plot_type_callback):
    """Create widgets used for visualizing content production."""
    comparison_selector = ipywidgets.SelectMultiple(
        options=[c for c in cfg.NODES if c != "Core Academic"],
        selected_labels=["Physics", "Biology", "Chemistry"])
    comparison_selector.height = '270px'
    type_selector1 = widgets.create_toggle(["videos", "exercises", "articles"],
                                           content_type_callback)
    type_selector2 = widgets.create_toggle(
        ["tutorials", "projects", "challenges"], content_type_callback)
    all_button = ipywidgets.Button(description="all",
                                   button_style="info",
                                   width="300px")
    all_button.on_click(content_type_callback)
    plot_selector = widgets.create_toggle(["Total Content", "Added Content"],
                                          plot_type_callback,
                                          style="primary",
                                          button_width="300px",
                                          orientation="vertical")
    title = ipywidgets.HTML(
        value='<div class=VizTitle><h2> Content Production </h2> </div>')
    toggle_container = ipywidgets.VBox(children=[
        title, widgets.gap, type_selector1, type_selector2, all_button,
        widgets.gap, plot_selector
    ],
                                       width="300px")
    prod_container = ipywidgets.HBox(
        children=[toggle_container, comparison_selector])
    return prod_container, comparison_selector
Example #22
0
 def _make_available_things(self):
     thing_selector = ipyw.SelectMultiple(
         options=self.available_things_list,
         disabled=False,
         layout=ipyw.Layout(height="300px"),
     )
     return thing_selector
Example #23
0
    def show_form(self):
        controllers.connect()
        tblist = controllers.TestBedController.all(like=None)
        runnables = find_runnables(exclude="analyze")

        self._tbselect = widgets.Select(options=tblist, description="Testbed:")
        self._rselect = widgets.SelectMultiple(
            options=runnables,
            description="Runnable Objects:",
            layout=widgets.Layout(width="60%", height="120px"))

        self._run_button = widgets.Button(description="Run",
                                          tooltip="Run",
                                          icon="play",
                                          button_style="primary")
        self._run_button.on_click(self._on_run)
        self._persist_cb = widgets.Checkbox(value=False,
                                            description="Record Results",
                                            disabled=False)
        tbbox = widgets.VBox([self._tbselect, self._persist_cb])
        display.display(
            widgets.VBox(
                [widgets.HBox([self._rselect, tbbox]), self._run_button]))
        self._out = widgets.Output()
        self._tblist = tblist
        self._runnables = runnables
Example #24
0
 def __init__(self, show_add_buy=True, add_button_style='default'):
     self.factor_dict = {}
     self.factor_wg_array = []
     # 策略候选池可x轴左右滚动
     self.factor_layout = widgets.Layout(overflow_x='scroll',
                                         # flex_direction='row',
                                         display='flex')
     self.selected_factors = widgets.SelectMultiple(
         options=[],
         description=u'已添加策略:',
         disabled=False,
         layout=widgets.Layout(width='100%', align_items='stretch')
     )
     # 已添加的全局策略可点击删除
     self.selected_factors.observe(self.remove_factor, names='value')
     # 全局策略改变通知接收序列
     self.selected_factors_obs = set()
     self.factor_box = None
     # 默认不启动可滚动因子界面,因为对外的widget版本以及os操作系统不统一
     self.scroll_factor_box = False
     self._sub_children_group_cnt = 3
     self.show_add_buy = show_add_buy
     self.add_button_style = add_button_style
     # 构建具体子类的界面构建
     self._init_widget()
     if self.factor_box is None:
         raise RuntimeError('_init_widget must build factor_box!')
     self.widget = widgets.VBox([self.factor_box, self.selected_factors])
Example #25
0
 def __init__(self, logspath):
     self.logs = sorted([(x.name, x) for x in logspath.iterdir()],
                        reverse=True)
     self.select = widgets.SelectMultiple(options=self.logs,
                                          rows=10,
                                          layout={'width': '100%'})
     display(self.select)
Example #26
0
 def __init__(self, context):
     self.context = context
     all_dfs = self.calculate()
     # by standard, df files must be inside IPTS/raw/DF, but older IPTS may not conform.
     # in that case, a general file selector is used
     if not all_dfs:
         return self.createDFFilesSelector()
     # select files at standard place
     explanation1 = ipyw.HTML(
         "Dark field (DF) measurements are needed for background correction. "
         "Please select the DF files from below. "
         "Use Shift-click or Ctrl-click to select multiple files")
     self.select = ipyw.SelectMultiple(value=[],
                                       options=all_dfs,
                                       description="DF files",
                                       layout=ipyw.Layout(margin="20px",
                                                          width="600px"))
     self.ok = ipyw.Button(description='OK',
                           layout=ipyw.Layout(margin="20px"))
     self.ok.on_click(self.validate)
     # button to switch to arbitrary files selector
     self.use_arbitrary_files_selector = ipyw.Button(
         description=
         'If you cannot find your DF files above, click me instead',
         layout=ipyw.Layout(margin="0 0 0 200px", width="350px"))
     self.use_arbitrary_files_selector.on_click(self.switchToFilesSelector)
     #
     self.widgets = [
         self.createSkipButton(), explanation1, self.select, self.ok,
         self.use_arbitrary_files_selector
     ]
     self.panel = ipyw.VBox(children=self.widgets, layout=self.layout)
Example #27
0
def createColumnWidgets(moduleNames, componentLists, nameList, selectedLists,
                        leftVBox, rightVBox):  # noqa
    hBoxChildren = []
    for module in moduleNames:
        vBox = widgets.VBox()

        label = widgets.HTML('<h4>' + module + '</h4>')
        textBox = widgets.Text(value='',
                               placeholder=str('Enter ' + module + ' name'),
                               layout=widgets.Layout(width='265px'),
                               description='Name:',
                               style={'description_width': '40px'},
                               disabled=False)
        selectList = widgets.SelectMultiple(
            options=componentLists[module],
            description='',
            rows=20,
            layout=widgets.Layout(width='265px'))  # noqa

        nameList.append(textBox)
        selectedLists.append(selectList)

        vBox.children = [label, textBox, selectList]

        hBoxChildren.append(vBox)

        if module == 'Device-Test-Context':
            hBoxChildren.append(leftVBox)

        if module == 'Device-Test':
            hBoxChildren.append(rightVBox)

    return hBoxChildren
    def __init__(self, mol):
        super(ResidueSelector, self).__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.HTML('<b>Selected residues:</b>')
        self.residue_list = ipy.SelectMultiple(options=list(), height=150)
        traitlets.directional_link((self.viewer, 'selected_atom_indices'),
                                   (self.residue_list, 'options'),
                                   self._atoms_to_residues)
        self.residue_list.observe(self.remove_atomlist_highlight, 'value')
        self.atom_list.observe(self.remove_reslist_highlight, 'value')

        self.subtools.children = [
            ipy.HBox([self.select_all_atoms_button, self.select_none])
        ]
        self.toolpane.children = [
            self.selection_type, self.atom_listname, self.atom_list,
            self.residue_listname, self.residue_list
        ]
Example #29
0
 def _make_selected_things(self):
     selected_things = ipyw.SelectMultiple(
         options=self.selected_things_list,
         disabled=False,
         layout=ipyw.Layout(height="300px"),
     )
     return selected_things
Example #30
0
    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')