Exemplo n.º 1
0
    def reload_body(self, raster):
        """dynamically change the body of the widget according to the raster file"""

        # empty the tbody children
        self.tbody.children = []

        # get the file features :
        features = cs.unique(raster)

        # create 1 line for each feature
        tmp_children = []
        for i in features:

            # create a textField
            field = v.TextField(placeholder="any value in [0, 256[",
                                type='number',
                                v_model=None,
                                value=i)

            # js link to the global widget
            field.observe(self._on_change, 'v_model')

            # wrap it in a row
            row = v.Html(tag='tr',
                         children=[
                             v.Html(tag='td', children=[str(i)]),
                             v.Html(tag='td', children=[field])
                         ])

            # add the row to the tbody
            tmp_children += [row]

        self.tbody.children += tmp_children

        return self
Exemplo n.º 2
0
    def _on_change(self, change):
        """update the list according to the file selection"""

        # get the nb_class
        nb_class = len(self.classes)

        # empty all select
        for i in range(nb_class):
            self.classes[i].v_model = None

        # get all unique values from the image
        features = cs.unique(change['new'])

        # add the new list as items
        for i in range(nb_class):
            self.classes[i].items = features

        return self
Exemplo n.º 3
0
    def _on_valid_band(self, change):

        # switch band status
        # cannot be done in the switch decorator as there number is
        # undertermined at class creation
        for w in self.classes:
            w.loading = True

        # exit if none
        if change["new"] is None:
            return self

        # get the unique features
        features = cs.unique(self.file.v_model, self.band.v_model)
        for w in self.classes:
            w.items = features

        # switch back the states
        for w in self.classes:
            w.loading = False

        return self