Esempio n. 1
0
    def __init__(self, io):

        # create the widgets
        connectivity = v.Select(label=cm.acc.connectivity,
                                items=cp.connectivity,
                                v_model=cp.connectivity[0]['value'])
        res = v.TextField(label=cm.acc.res,
                          type='number',
                          v_model=None,
                          hint=cm.acc.res_hint)
        thresholds = cw.Thresholds(label=cm.acc.thresholds)
        options = v.Select(label=cm.acc.options,
                           items=cp.acc_options,
                           v_model=cp.acc_options[0]['value'])

        # bind to the io
        self.output = sw.Alert() \
            .bind(connectivity, io, 'connectivity') \
            .bind(res, io, 'res') \
            .bind(thresholds.save, io, 'thresholds') \
            .bind(options, io, 'options')

        # extra js behaviour
        res.on_event('focusout', self._on_focus_out)

        super().__init__(io=io,
                         output=self.output,
                         inputs=[connectivity, res, thresholds, options])
Esempio n. 2
0
    def __init__(self, model):

        # create the widgets
        connectivity = v.Select(
            label=cm.acc.connectivity,
            items=cp.connectivity,
            v_model=cp.connectivity[0]["value"],
        )
        prescision = v.Select(
            label=cm.fad.prescision,
            items=cp.prescision,
            v_model=cp.prescision[0]["value"],
        )
        options = v.Select(
            label=cm.acc.options,
            items=cp.fad_options,
            v_model=cp.fad_options[0]["value"],
        )

        # bind to the io
        (
            model.bind(connectivity, "connectivity")
            .bind(prescision, "prescision")
            .bind(options, "options")
        )

        super().__init__(
            model=model,
            inputs=[connectivity, prescision, options],
        )
Esempio n. 3
0
    def __init__(self, cases):
        """
        Widget definition for models.

        Parameters
        ==========

        cases: dict
            the keys of this dictionary are the name of the model,
            the values of this dictionary are an instance of the model.

        This widget is composed by a menu where you can choose the dimension
        and the model.

        This widget is also composed by a main widget
        where a description of the model is given.

        """
        self.cases = cases
        default_category = next(iter(self.cases))

        ##
        ## The menu
        ##

        # widget to select the model
        self.select_category = v.Select(
            items=list(self.cases.keys()),
            v_model=default_category,
            label='Category',
        )
        self.select_model = v.Select(
            items=[],
            v_model=None,
            label='Model'
        )
        self.menu = [self.select_category, self.select_model]

        ##
        ## The main
        ##

        self.description = HTML()

        self.tabs = v.Tabs(
            v_model=None,
            children=[
                v.Tab(children=['Description']),
                v.TabItem(children=[self.description]),
            ]
        )

        self.main = [self.tabs]

        # Add the widget events
        self.select_category.observe(self.change_category, 'v_model')
        self.select_model.observe(self.change_model, 'v_model')

        # update the category to fix the default model
        self.change_category(None)
Esempio n. 4
0
    def __init__(self, io):

        # create the widgets
        connectivity = v.Select(label=cm.acc.connectivity,
                                items=cp.connectivity,
                                v_model=cp.connectivity[0]['value'])
        res = v.TextField(label=cm.acc.res,
                          type='number',
                          v_model=None,
                          hint=cm.acc.res_hint)
        windows = cw.Windows(label=cm.frag.windows)
        options = v.Select(label=cm.acc.options,
                           items=cp.fad_options,
                           v_model=cp.fad_options[0]['value'])

        prescision = v.Select(label=cm.fad.prescision,
                              items=cp.prescision,
                              v_model=cp.prescision[0]['value'])

        # bind to the io
        self.output = sw.Alert() \
            .bind(connectivity, io, 'connectivity') \
            .bind(res, io, 'res') \
            .bind(windows.save, io, 'window_size') \
            .bind(options, io, 'options') \
            .bind(prescision, io, 'prescision')

        # extra js behaviour
        res.on_event('focusout', self._on_focus_out)

        super().__init__(
            io=io,
            inputs=[connectivity, res, windows, options, prescision],
            output=self.output)
Esempio n. 5
0
    def __init__(self, io):

        # create the widgets
        algorithm = v.Select(label=cm.p223.algo,
                             items=cp.algo,
                             v_model=cp.algo[0]['value'])
        kdim = v.TextField(label=cm.lm.kdim,
                           type='number',
                           hint=cm.frag.invalid_window,
                           v_model=None)
        prescision = v.Select(label=cm.fad.prescision,
                              items=cp.prescision,
                              v_model=cp.prescision[0]['value'])

        # bind to the io
        self.output = sw.Alert() \
            .bind(algorithm, io, 'algorithm') \
            .bind(kdim, io, 'kdim') \
            .bind(prescision, io, 'prescision')

        # create extra js behaviour
        kdim.on_event('focusout', self._on_focusout)

        super().__init__(io=io,
                         inputs=[
                             algorithm,
                             kdim,
                             prescision,
                         ],
                         output=self.output)
Esempio n. 6
0
    def __init__(self):
        self.label = v.TextField(label='label', v_model='')
        self.line_style = v.Select(label='Line style',
                                   items=[{
                                       'text': v,
                                       'value': k
                                   } for k, v in Line2D.lineStyles.items()],
                                   v_model=plot_config['linestyle'])
        self.line_width = IntField(label='linewidth',
                                   v_model=plot_config['linewidth'])
        self.marker = v.Select(label='Marker',
                               items=[{
                                   'text': v,
                                   'value': k
                               } for k, v in Line2D.markers.items()],
                               v_model=plot_config['marker'])
        self.marker_size = IntField(label='Marker size',
                                    v_model=plot_config['markersize'])
        self.alpha = FloatField(label='alpha', v_model=plot_config['alpha'])
        self.color = v.ColorPicker(v_model=plot_config['colors'][0])

        self.widget = [
            self.label,
            self.line_style,
            self.line_width,
            self.marker,
            self.marker_size,
            self.alpha,
            v.Row(children=[self.color], justify='center'),
        ]
Esempio n. 7
0
    def __init__(self, model):

        # create the widgets
        connectivity = v.Select(
            label=cm.acc.connectivity,
            items=cp.connectivity,
            v_model=cp.connectivity[0]["value"],
        )
        res = v.TextField(
            label=cm.acc.res, type="number", v_model=None, hint=cm.acc.res_hint
        )
        thresholds = cw.Thresholds(label=cm.acc.thresholds)
        options = v.Select(
            label=cm.acc.options,
            items=cp.acc_options,
            v_model=cp.acc_options[0]["value"],
        )
        big_3_pink = v.Switch(label=cm.acc.big3pink, v_model=True)

        # bind to the
        (
            model.bind(connectivity, "connectivity")
            .bind(res, "res")
            .bind(thresholds.save, "thresholds")
            .bind(options, "options")
            .bind(big_3_pink, "big_3_pink")
        )

        # extra js behaviour
        res.on_event("focusout", self._on_focus_out)

        super().__init__(
            model=model, inputs=[connectivity, res, thresholds, options, big_3_pink]
        )
Esempio n. 8
0
    def __init__(self, label='vector_file', **kwargs):

        # save the df for column naming (not using a gdf as geometry are useless)
        self.df = None

        # set the 3 wigets
        self.w_file = FileInput(['.shp', '.geojson', '.gpkg', '.kml'],
                                label=label)
        self.w_column = v.Select(_metadata={'name': 'column'},
                                 items=self.column_base_items,
                                 label='Column',
                                 v_model='ALL')
        self.w_value = v.Select(_metadata={'name': 'value'},
                                items=[],
                                label='Value',
                                v_model=None)
        su.hide_component(self.w_value)

        # create the Col Field
        self.children = [self.w_file, self.w_column, self.w_value]
        self.v_model = self.default_v_model

        super().__init__(**kwargs)

        # events
        self.w_file.observe(self._update_file, 'v_model')
        self.w_column.observe(self._update_column, 'v_model')
        self.w_value.observe(self._update_value, 'v_model')
Esempio n. 9
0
    def __init__(self, label="Table file"):

        self.fileInput = FileInput(['.csv', '.txt'], label=label)

        self.IdSelect = v.Select(_metadata={'name': 'id_column'},
                                 items=[],
                                 label='Id',
                                 v_model=None)
        self.LngSelect = v.Select(_metadata={'name': 'lng_column'},
                                  items=[],
                                  label='Longitude',
                                  v_model=None)
        self.LatSelect = v.Select(_metadata={'name': 'lat_column'},
                                  items=[],
                                  label='Latitude',
                                  v_model=None)

        super().__init__(v_model=self.default_v_model,
                         children=[
                             self.fileInput, self.IdSelect, self.LngSelect,
                             self.LatSelect
                         ])

        # link the dropdowns
        jslink((self.IdSelect, 'items'), (self.LngSelect, 'items'))
        jslink((self.IdSelect, 'items'), (self.LatSelect, 'items'))

        # link the widget with v_model
        self.fileInput.observe(self._on_file_input_change, 'v_model')
        self.IdSelect.observe(self._on_select_change, 'v_model')
        self.LngSelect.observe(self._on_select_change, 'v_model')
        self.LatSelect.observe(self._on_select_change, 'v_model')
Esempio n. 10
0
    def __init__(self, phys_fields, *args, **kwargs):
        self.phys_fields = phys_fields
        self.select_field = v.Select(label='Fields',
                                     v_model=[],
                                     items=['all'] + phys_fields,
                                     required=True,
                                     multiple=True)
        self.select_when = v.Select(label='When',
                                    v_model=None,
                                    items=[t.value for t in SaveType],
                                    required=True)
        self.when_properties = v.TextField(label='when save the fields?',
                                           v_model=None,
                                           required=True)

        self.select_field.observe(self.select_fields_rules, 'v_model')
        self.select_field.observe(self.select_fields_all, 'v_model')
        self.select_when.observe(self.select_when_rules, 'v_model')
        self.select_when.observe(self.when_properties_rules, 'v_model')
        self.when_properties.observe(self.when_properties_rules, 'v_model')

        self.fields = [
            self.select_field, self.select_when, self.when_properties
        ]

        super().__init__(v_model='valid',
                         children=[
                             self.select_field,
                             self.select_when,
                             self.when_properties,
                         ])
Esempio n. 11
0
    def __init__(self, model, aoi_model, viz_tile, export_tile, **kwargs):

        # Define the model and the aoi_model as class attribute so that they can be manipulated in its custom methods
        self.model = model
        self.aoi_model = aoi_model

        # LINK to the result tile
        self.viz_tile = viz_tile
        self.export_tile = export_tile

        # WIDGETS
        self.year_beg = v.Select(
            label=cm.process.slider_b,
            v_model=None,
            items=[i for i in range(pm.max_year, pm.min_year - 1, -1)],
        )

        self.year_end = v.Select(
            label=cm.process.slider_e,
            v_model=None,
            items=[i for i in range(pm.max_year, pm.min_year - 1, -1)],
        )

        self.type_tmf = v.RadioGroup(
            row=True,
            v_model=pm.layer_select[0]["value"],
            children=[
                v.Radio(key=e["key"], label=e["label"], value=e["value"])
                for e in pm.layer_select
            ],
        )

        # self.type_tmf.observe(self._on_change, 'v_model')

        # Create the alert alert
        self.model.bind(self.year_beg, "year_beg").bind(
            self.year_end, "year_end").bind(self.type_tmf, "type_tmf")

        # construct the Tile with the widget we have initialized
        super().__init__(
            id_=
            "process_widget",  # the id will be used to make the Tile appear and disapear
            title=cm.process.
            title,  # the Title will be displayed on the top of the tile
            inputs=[self.year_beg, self.year_end, self.type_tmf],
            btn=sw.Btn(cm.process.validate,
                       "mdi-check",
                       disabled=False,
                       class_="ma-5"),
            alert=sw.Alert(),
        )

        # now that the Tile is created we can link it to a specific function
        self.btn.on_event("click", self._on_run)
Esempio n. 12
0
    def __init__(self, aoi_model, model, **kwargs):

        # gather the model
        self.aoi_model = aoi_model
        self.model = model

        # widgets
        self.stats = v.Select(
            label=ms.export.stats,
            v_model=model.stats,
            items=pm.stats,
            chips=True,
            multiple=True,
        )
        self.temps = v.Select(
            label=ms.export.temps,
            v_model=model.temps,
            items=pm.temps,
            chips=True,
            multiple=True,
        )
        self.scale = v.TextField(label=ms.export.scale, v_model=30)

        # create buttons
        self.asset_btn = sw.Btn(ms.export.asset_btn,
                                "mdi-download",
                                disabled=True,
                                class_="ma-5")
        self.sepal_btn = sw.Btn(ms.export.sepal_btn,
                                "mdi-download",
                                disabled=True,
                                class_="ma-5")

        # bindings
        self.model.bind(self.stats,
                        "stats").bind(self.temps,
                                      "temps").bind(self.scale, "scale")

        # note that btn and output are not a madatory attributes
        super().__init__(
            id_="export_widget",
            title=ms.export.title,
            inputs=[self.stats, self.temps, self.scale],
            alert=sw.Alert(),
            btn=v.Layout(row=True, children=[self.asset_btn, self.sepal_btn]),
        )

        # link the btn
        self.asset_btn.on_event("click", self._on_asset_click)
        self.sepal_btn.on_event("click", self._on_sepal_click)
Esempio n. 13
0
    def __init__(self, label='', **kwargs):

        self.class_ = 'd-flex align-center mb-2'
        self.disabled = True
        self.row = True
        self.label = label

        super().__init__(**kwargs)

        self.w_prev = v.Btn(_metadata={'name': 'previous'},
                            x_small=True,
                            children=[
                                v.Icon(left=True,
                                       children=['mdi-chevron-left']), 'prev'
                            ])

        self.w_next = v.Btn(
            _metadata={'name': 'next'},
            x_small=True,
            children=[v.Icon(children=['mdi-chevron-right']), 'nxt'])

        self.w_list = v.Select(class_='ma-2',
                               label=self.label,
                               items=self.items,
                               v_model='')

        self.children = [self.w_prev, self.w_list, self.w_next]

        link((self.w_list, 'items'), (self, 'items'))
        link((self.w_list, 'v_model'), (self, 'v_model'))
        self.w_prev.on_event('click', self.prev_next_event)
        self.w_next.on_event('click', self.prev_next_event)
Esempio n. 14
0
    def __init__(self, io):

        # create the widgets
        connectivity = v.Select(label=cm.acc.connectivity,
                                items=cp.connectivity,
                                v_model=cp.connectivity[0]['value'])
        edge_width = v.Slider(label=cm.mspa.edge_width,
                              min=1,
                              max=30,
                              v_model=1)
        transition = v.Switch(label=cm.mspa.transition,
                              false_value=0,
                              true_value=1,
                              v_model=1)
        int_ext = v.Switch(label=cm.mspa.int_ext,
                           false_value=0,
                           true_value=1,
                           v_model=1)

        # bind to the io
        self.output = sw.Alert() \
            .bind(connectivity, io, 'connectivity') \
            .bind(edge_width, io, 'edge_width') \
            .bind(transition, io, 'transition') \
            .bind(int_ext, io, 'int_ext')

        super().__init__(
            io=io,
            inputs=[connectivity, edge_width, transition, int_ext],
            output=self.output)
Esempio n. 15
0
        def __init__(self, viz):
            super(type(self), self).__init__(column=True)
            self.viz = viz
            self.ds = self.viz.state.ds
            column_names = self.ds.get_column_names()
            self.x = v.Select(items=column_names, v_model=self.viz.state.x_expression, label='x axis')
            widgets.link((self.viz.state, 'x_expression'), (self.x, 'v_model'))

            self.y = v.Select(items=column_names, v_model=self.viz.state.y_expression, label='y axis')
            widgets.link((self.viz.state, 'y_expression'), (self.y, 'v_model'))

            self.normalize = v.Checkbox(label='normalize', v_model=self.viz.normalize)
            widgets.link((self.viz, 'normalize'), (self.normalize, 'v_model'))
            

            self.children = [self.x, self.y, self.normalize]
Esempio n. 16
0
    def __init__(self, io, nb_class):

        # gather the io
        self.io = io

        # create the widgets
        self.file = sw.FileInput(['.tif', '.tiff'])
        self.classes = [
            v.Select(label=cp.convert[nb_class]['label'][i],
                     items=None,
                     v_model=None,
                     chips=True,
                     multiple=True) for i in range(nb_class)
        ]
        requirements = sw.Markdown(cm.requirement[nb_class])

        # bind it to the io
        self.output = sw.Alert().bind(self.file, self.io, 'file')
        for i in range(nb_class):
            self.output.bind(self.classes[i], self.io,
                             cp.convert[nb_class]['io'][i])

        # create the btn
        btn = sw.Btn("Convert the imag classes")

        super().__init__(self.io.tile_id,
                         "Select map classes",
                         inputs=[requirements, self.file] + self.classes,
                         output=self.output,
                         btn=btn)

        # bind js event
        btn.on_event('click', self._on_click)
        self.file.observe(self._on_change, 'v_model')
Esempio n. 17
0
    def __init__(self):

        self.prev = v.Btn(_metadata={'increm': -1},
                          x_small=True,
                          class_='ml-2 mr-2',
                          color=sc.secondary,
                          children=[
                              v.Icon(children=['mdi-chevron-left']),
                              cm.dynamic_select.prev
                          ])

        self.next = v.Btn(_metadata={'increm': 1},
                          x_small=True,
                          class_='ml-2 mr-2',
                          color=sc.secondary,
                          children=[
                              cm.dynamic_select.next,
                              v.Icon(children=['mdi-chevron-right'])
                          ])

        self.select = v.Select(dense=True,
                               label=cm.dynamic_select.label,
                               v_model=None)

        super().__init__(v_model=None,
                         align_center=True,
                         row=True,
                         class_='ma-1',
                         children=[self.prev, self.select, self.next])

        # js behaviour
        jslink((self, 'v_model'), (self.select, 'v_model'))
        self.prev.on_event('click', self._on_click)
        self.next.on_event('click', self._on_click)
    def __init__(self, aoi_model, model, **kwargs):

        # gather the model
        self.aoi_model = aoi_model
        self.model = model

        # widgets
        self.measure = v.Select(label=ms.selection.measure,
                                v_model=None,
                                items=pm.measures)
        self.annual = v.Switch(class_="ml-5",
                               label=ms.selection.annual,
                               v_model=False)

        # add the map
        self.m = sm.SepalMap()

        # create an output alert
        self.model.bind(self.measure, "measure").bind(self.annual, "annual")

        # construct the Tile with the widget we have initialized
        super().__init__(
            id_=
            "visualization_widget",  # the id will be used to make the Tile appear and disapear
            title=ms.visualization.
            title,  # the Title will be displayed on the top of the tile
            inputs=[self.measure, self.annual, self.m],
            alert=sw.Alert(),
        )

        self.measure.observe(self._on_change, "v_model")
        self.annual.observe(self._on_change, "v_model")
def construct_selects_container(selects_meta: dict, title=None):
    """
    Constructs a group of selector dropdowns
    
    Accepts:
        - selects_meta: dict
            Mapping from the select labels to their respective 
            lists from which the selection will be pre-populated
        - title: str
            Label which will be added as a p tag at the top of
            the section container
            
    Returns:
        - selects_container
            Container object with each select as a child
    
    """

    selects_list = [
        v.Select(label=label, items=prepop_list, v_model="")
        for label, prepop_list in selects_meta.items()
    ]

    if title is not None:
        assert isinstance(title,
                          str), f"Title must be a string, not {type(title)}"
        selects_list = [v.Html(tag="p", children=[title])] + selects_list

    selects_container = v.Container(children=selects_list)

    return selects_container
Esempio n. 20
0
    def __init__(self, test_case_widget, lb_scheme_widget):

        self.responses = {}

        self.responses_list = v.Select(label='Responses',
                                       v_model=[],
                                       items=[],
                                       multiple=True)

        def update_responses(change):
            test_case = test_case_widget.get_case()
            lb_scheme = lb_scheme_widget.get_case()

            self.responses = build_responses_list(test_case, lb_scheme)

            self.responses_list.items = ['all'] + list(self.responses.keys())

        def select_all(change):
            if 'all' in self.responses_list.v_model:
                self.responses_list.v_model = list(self.responses.keys())

        update_responses(None)

        self.responses_list.observe(select_all, 'v_model')

        test_case_widget.select_case.observe(update_responses, 'v_model')
        lb_scheme_widget.select_case.observe(update_responses, 'v_model')
        self.widget = self.responses_list
Esempio n. 21
0
    def __init__(self, test_case_widget, lb_scheme_widget, discret_widget,
                 **kwargs):
        self.test_case_widget = test_case_widget
        self.lb_scheme_widget = lb_scheme_widget
        self.discret_widget = discret_widget
        self.params, self.relax_params = None, None

        self.select_param = v.Select(label='Parameters',
                                     v_model=None,
                                     items=[])
        self.select_relax = v.Select(label='relaxation rates',
                                     v_model=[],
                                     items=[],
                                     multiple=True,
                                     class_='d-none')
        self.srt_relax = v.Switch(label='Single relaxation time',
                                  v_model=True,
                                  class_='d-none')
        self.sigma = v.Switch(label='Using sigma',
                              v_model=False,
                              class_='d-none')
        self.in_log = v.Switch(label='Using log10',
                               v_model=False,
                               class_='d-none')
        self.minmax = v.Layout()

        self.update_select_fields(None)

        test_case_widget.select_case.observe(self.update_select_fields,
                                             'v_model')
        lb_scheme_widget.select_case.observe(self.update_select_fields,
                                             'v_model')
        discret_widget['dx'].observe(self.update_select_fields, 'v_model')

        self.fields = [
            self.select_param, self.select_relax, self.srt_relax, self.sigma,
            self.in_log, self.minmax
        ]

        super().__init__(v_model='valid', children=self.fields)

        self.select_param.observe(self.select_param_changed, 'v_model')
        self.select_relax.observe(self.select_relax_all, 'v_model')
        self.select_relax.observe(self.check_changes, 'v_model')
        self.in_log.observe(self.check_changes, 'v_model')
        self.sigma.observe(self.check_changes, 'v_model')
Esempio n. 22
0
    def __init__(self, model, aoi_model, viz_tile, export_tile, **kwargs):

        # Define the model and the aoi_model as class attribute so that they can be manipulated in its custom methods
        self.model = model
        self.aoi_model = aoi_model

        # Link to the result tile
        self.viz_tile = viz_tile
        self.export_tile = export_tile

        # widgets
        self.year = v.Select(label=ms.process.slider,
                             v_model=None,
                             items=pm.years[::-1])

        self.filter = v.Select(label=ms.process.filter,
                               v_model=None,
                               items=pm.speckle_filters)

        self.ls_mask = v.Switch(class_="ml-5",
                                label=ms.process.ls_mask,
                                v_model=True)

        self.dB = v.Switch(class_="ml-5", label=ms.process.dB, v_model=True)

        # it also has the embeded `bind` method that link mutable variable to component v_model
        # bind return self so it can be chained to bind everything in one statement.
        # args are (widget, model, model_attribute_name)
        self.model.bind(self.year, "year").bind(self.filter, "filter").bind(
            self.ls_mask, "ls_mask").bind(self.dB, "dB")

        # construct the Tile with the widget we have initialized
        super().__init__(
            id_=
            "process_widget",  # the id will be used to make the Tile appear and disapear
            title=ms.process.
            title,  # the Title will be displayed on the top of the tile
            inputs=[self.year, self.filter, self.ls_mask,
                    self.dB],  # self.asset,
            btn=sw.Btn(ms.process.process),
            alert=sw.Alert(),
        )

        # now that the Tile is created we can link it to a specific function
        self.btn.on_event("click", self._on_run)
Esempio n. 23
0
    def __init__(self, model):

        # create the widgets
        options = v.Select(label=cm.spa.nb_classes, items=cp.spa_options, v_model=None)

        # bind to the io
        model.bind(options, "options")

        super().__init__(model=model, inputs=[options])
Esempio n. 24
0
    def __init__(self, io):

        # create the widgets
        connectivity = v.Select(label=cm.acc.connectivity,
                                items=cp.connectivity,
                                v_model=cp.connectivity[0]['value'])
        options = v.Select(label=cm.acc.options,
                           items=cp.dist_options,
                           v_model=cp.dist_options[0]['value'])

        # bind to the io
        self.output = sw.Alert() \
            .bind(connectivity, io, 'connectivity') \
            .bind(options, io, 'options')

        super().__init__(io=io,
                         inputs=[connectivity, options],
                         output=self.output)
Esempio n. 25
0
    def __init__(self, table, **kwargs):
        self.table = table

        update = v.Btn(children=['update'])
        close = v.Btn(children=['close'])

        self.form = [
            IntField(label='linewidth', v_model=plot_config['linewidth']),
            v.Select(label='Line style',
                     items=[{
                         'text': v,
                         'value': k
                     } for k, v in Line2D.lineStyles.items()],
                     v_model=plot_config['linestyle']),
            v.Select(label='Marker',
                     items=[{
                         'text': v,
                         'value': k
                     } for k, v in Line2D.markers.items()],
                     v_model=plot_config['marker']),
            IntField(label='Marker size', v_model=plot_config['markersize']),
            FloatField(label='alpha', v_model=plot_config['alpha']),
            v.ColorPicker(v_model=plot_config['colors'][0]),
        ]

        self.dialog = v.Dialog(
            width='500',
            v_model=False,
            children=[
                v.Card(children=[
                    v.CardTitle(class_='headline gray lighten-2',
                                primary_title=True,
                                children=['Plot properties']),
                    v.CardText(children=self.form),
                    v.CardActions(children=[v.Spacer(), update, close])
                ]),
            ])

        def close_btn(widget, event, data):
            self.dialog.v_model = False

        update.on_event('click', self.update_btn)
        close.on_event('click', close_btn)
        super().__init__(**kwargs)
Esempio n. 26
0
    def __init__(self, aoi_model, model, viz_tile, export_tile, **kwargs):

        # gather the model
        self.aoi_model = aoi_model
        self.model = model
        self.viz_tile = viz_tile
        self.export_tile = export_tile

        # widgets
        w_time_title = v.Html(tag="H3",
                              class_="mt-3",
                              children=[ms.selection.time_range])
        self.start_picker = sw.DatePicker(label=ms.selection.start)
        self.end_picker = sw.DatePicker(label=ms.selection.end)
        w_time_range = v.Layout(row=True,
                                children=[self.start_picker, self.end_picker])

        w_collection_title = v.Html(tag="H3",
                                    class_="mt-3",
                                    children=[ms.selection.collection])
        self.sensors = v.Select(
            label=ms.selection.sensor,
            items=pm.sensors,
            v_model=None,
            chips=True,
            multiple=True,
        )
        self.t2 = v.Switch(class_="ml-5", label=ms.selection.t2, v_model=False)
        self.sr = v.Switch(class_="ml-5", label=ms.selection.sr, v_model=False)

        self.model.bind(self.start_picker,
                        "start").bind(self.end_picker, "end").bind(
                            self.sensors,
                            "sensors").bind(self.t2, "t2").bind(self.sr, "sr")

        # construct the Tile with the widget we have initialized
        super().__init__(
            id_=
            "selection_widget",  # the id will be used to make the Tile appear and disapear
            title=ms.selection.
            title,  # the Title will be displayed on the top of the tile
            inputs=[
                w_time_title,
                w_time_range,
                w_collection_title,
                self.sensors,
                self.t2,
                self.sr,
            ],
            btn=sw.Btn(ms.selection.btn),
            alert=sw.Alert(),
        )

        # now that the Tile is created we can link it to a specific function
        self.btn.on_event("click", self._on_run)
Esempio n. 27
0
    def __init__(self,
                 class_path=Path("~").expanduser() / "downloads",
                 *args,
                 **kwargs):
        """Stand-alone tile composed by a select widget containing .csv reclassify files
        found in the class_path, and a ClassTable to edit and/or create a new
        classification table,

        Args:
            class_path (str) (optional): Folder path containing classification tables
        """

        super().__init__(*args, **kwargs)

        self.title = v.CardTitle(
            children=["Edit or create new classifications"])
        self.class_path = class_path

        self.w_class_file = v.Select(
            label="Select a classes file",
            items=self.get_items(),
            v_model="",
            dense=True,
        )
        self.ct = ClassTable(
            out_path=self.class_path,
            schema={
                "id": "number",
                "code": "number",
                "description": "string"
            },
        ).hide()

        use_btn = sw.Btn("Get table")
        self.children = [
            self.title,
            v.Flex(
                class_="ml-2 d-flex",
                children=[
                    self.w_class_file,
                    use_btn,
                ],
            ),
            self.ct,
        ]
        self.get_classes_files()

        # Events

        # Listen Class table save dialog to refresh the classes widget
        self.ct.save_dialog.observe(self._refresh_files, "reload")

        # Get the corresponding table
        use_btn.on_event("click", self.get_class_table)
Esempio n. 28
0
    def __init__(self, io):

        # create the widgets
        connectivity = v.Select(label=cm.acc.connectivity,
                                items=cp.connectivity,
                                v_model=cp.connectivity[0])

        # bind to the io
        self.output = sw.Alert() \
            .bind(connectivity, io, 'connectivity')

        super().__init__(io=io, inputs=[connectivity], output=self.output)
Esempio n. 29
0
    def __init__(self, model):

        # create the widgets
        connectivity = v.Select(
            label=cm.acc.connectivity,
            items=cp.connectivity,
            v_model=cp.connectivity[0]["value"],
        )

        # bind to the io
        model.bind(connectivity, "connectivity")

        super().__init__(model=model, inputs=[connectivity])
Esempio n. 30
0
    def __init__(self, io, nb_class):

        # gather the io
        self.io = io

        # create the download layout
        self.down_test = sw.Btn(cm.bin.default.btn,
                                icon="mdi-cloud-download-outline",
                                small=True,
                                outlined=True,
                                class_="ma-5")
        tooltip = sw.Tooltip(widget=self.down_test,
                             tooltip=cm.bin.default.tooltip)

        # create the widgets

        self.file = sw.FileInput(['.tif', '.tiff'])
        self.classes = [
            v.Select(label=cp.convert[nb_class]['label'][i],
                     items=None,
                     v_model=None,
                     chips=True,
                     small_chips=True,
                     multiple=True,
                     dense=True,
                     deletable_chips=True)
            for i in range(len(cp.convert[nb_class]['label']))
        ]
        requirements = sw.Markdown(cm.requirement[nb_class])

        # bind it to the io
        self.output = sw.Alert().bind(self.file, self.io, 'file')
        for i in range(len(cp.convert[nb_class]['label'])):
            self.output.bind(self.classes[i], self.io,
                             cp.convert[nb_class]['io'][i])

        # create the btn
        btn = sw.Btn(cm.bin.btn)

        super().__init__(
            self.io.tile_id,
            cm.bin.title,
            inputs=[tooltip, v.Divider(), requirements, self.file] +
            self.classes,
            output=self.output,
            btn=btn)

        # bind js event
        btn.on_event('click', self._on_click)
        self.file.observe(self._on_change, 'v_model')
        self.down_test.on_event('click', self._on_download)