Ejemplo n.º 1
0
    def __init__(self, items=[], code=None, wiki=None, issue=None, **kwargs):

        self.items = items

        code_link = []
        if code:
            item_code = DrawerItem('Source code',
                                   icon='mdi-file-code',
                                   href=code)
            code_link.append(item_code)
        if wiki:
            item_wiki = DrawerItem('Wiki',
                                   icon='mdi-book-open-page-variant',
                                   href=wiki)
            code_link.append(item_wiki)
        if issue:
            item_bug = DrawerItem('Bug report', icon='mdi-bug', href=issue)
            code_link.append(item_bug)

        super().__init__(v_model=True,
                         app=True,
                         color=sepal_darker,
                         children=[
                             v.List(dense=True, children=self.items),
                             v.Divider(),
                             v.List(dense=True, children=code_link)
                         ],
                         **kwargs)

        # bind the javascripts behavior
        for i in self.items:
            i.observe(self._on_item_click, 'input_value')
Ejemplo n.º 2
0
    def __init__(self, items, code=None, wiki=None, issue=None, **kwargs):

        code_link = []
        if code:
            item_code = DrawerItem('Source code',
                                   icon='mdi-file-code',
                                   href=code)
            code_link.append(item_code)
        if wiki:
            item_wiki = DrawerItem('Wiki',
                                   icon='mdi-book-open-page-variant',
                                   href=wiki)
            code_link.append(item_wiki)
        if issue:
            item_bug = DrawerItem('Bug report', icon='mdi-bug', href=issue)
            code_link.append(item_bug)

        super().__init__(v_model=True,
                         app=True,
                         color=sepal_darker,
                         children=[
                             v.List(dense=True, children=items),
                             v.Divider(),
                             v.List(dense=True, children=code_link)
                         ],
                         **kwargs)
Ejemplo n.º 3
0
    def __init__(self):

        with cp.eula_md.open() as f:
            licence = f.read()
        mkd = sw.Markdown(licence)
        text = v.CardText(children=[mkd])

        btn = v.CardActions(children=[sw.Btn(cm.app.licence.btn)])

        self.card = v.Card(children=[btn, v.Divider(), text, v.Divider(), btn])

        super().__init__(value=not self._is_gwb(),
                         max_width='1000px',
                         children=[self.card],
                         persistent=True)

        # link the btn behaviour
        btn.on_event('click', self._set_gwb)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    def __init__(self, aoi_model, model, result_tile):

        # build the tiles
        time_tile = (TimeTile(model), )
        sensor_tile = (SensorTile(model), )
        basemap_tile = (BasemapTile(model), )
        input_tile = FcdmTile(model)
        launch_tile = LaunchTile(aoi_model, model, result_tile)

        tiles = [time_tile, sensor_tile, basemap_tile, input_tile, launch_tile]

        # build the content and the stepper header
        step_content = []
        stepper_children = []
        for i, tile in enumerate(tiles):

            # for no reason the tiles are sometimes embed in a len 1 tuple
            tile = tile if type(tile) != tuple else tile[0]

            # build the stepper
            stepper_children.append(
                v.StepperStep(
                    key=i + 1,
                    complete=False,
                    step=i + 1,
                    editable=True,
                    children=[tile.get_title()],
                ))
            stepper_children.append(v.Divider())

            # build the content
            step_content.append(
                v.StepperContent(key=i + 1, step=i + 1, children=[tile]))

        # remove the last divider
        stepper_children.pop()

        # build the stepper
        stepper = v.Stepper(
            class_="mt-2",
            children=[
                v.StepperHeader(children=stepper_children),
                v.StepperItems(children=step_content),
            ],
        )

        # build the tile
        super().__init__("questionnaire_tile",
                         cm.tile.questionnaire,
                         inputs=[stepper])
Ejemplo n.º 6
0
def NavDrawer(items, code = False, wiki = False, issue = None):
    """ 
    create a navdrawer using the different items of the user and the sepal color framework. The drawer always include links to the github page of the project for wiki, bugs and repository.
    
    Args:
        items ([v.ListItem]) : the list of the list item the user wants to add to the nav drawer
        code (str, optionnal) : the absolute link to the github code. not display if None
        wiki (str, optionnal) : the absolute link to the github wiki. not display if None
        issue (str, optionnal) : the absolute link to the github issues. not display if None
    
    Returns:
        navDrawer (v.NavigationDrawer) : the nav drawer of the web page
    """
    
    code_link = []
    if code:
        item_code = DrawerItem('Source code', icon='mdi-file-code', href=code)
        code_link.append(item_code)
    if wiki:
        item_wiki = DrawerItem('Wiki', icon='mdi-book-open-page-variant', href=wiki)
        code_link.append(item_wiki)
    if issue:
        item_bug = DrawerItem('Bug report', icon='mdi-bug', href=issue)
        code_link.append(item_bug)
        
    
        
    navDrawer = v.NavigationDrawer(
        v_model=True, 
        app= True,
        color=sepal_darker,
        children=[
            v.List(dense=True, children=items),
            v.Divider(),
            v.List(dense=True, children=code_link),
        ]
    )
    
    return navDrawer
Ejemplo n.º 7
0
    def __init__(self, model, nb_class):

        # gather the model
        self.model = model

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

        # create the widgets
        file = v.Html(tag="h3", children=[cm.bin.file])
        self.file = sw.FileInput([".tif", ".tiff", ".vrt"])
        self.band = v.Select(label=cm.bin.band, items=None, v_model=None)
        reclassify = v.Html(tag="h3", children=[cm.bin.classes], class_="mb-3")
        self.classes = [
            v.Select(
                label=cp.convert[nb_class]["label"][i],
                items=None,
                v_model=[],
                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 model
        self.model.bind(self.file, "file")
        for i in range(len(cp.convert[nb_class]["label"])):
            self.model.bind(self.classes[i], cp.convert[nb_class]["io"][i])

        super().__init__(
            self.model.tile_id,
            cm.bin.title,
            inputs=[
                mkd_txt,
                self.down_test,
                v.Divider(),
                requirements,
                file,
                self.file,
                self.band,
                reclassify,
                *self.classes,
            ],
            alert=sw.Alert(),
            btn=sw.Btn(cm.bin.btn),
        )

        # bind js event
        self.btn.on_event("click", self._on_click)
        self.file.observe(self._on_change, "v_model")
        self.band.observe(self._on_valid_band, "v_model")
        self.down_test.on_event("click", self._on_download)
Ejemplo n.º 8
0
def statistics_tile(w_selector, statistics_io):
    def on_click(widget, event, data, path_selector, date_selector, statistic,
                 alert, out):

        # Clear output if there is something printed before
        out.clear_output()

        # Once the button is clicked, disable it
        btn.disable()

        # Clear old alert messages
        alert.clear()

        @out.capture()
        def run_process(path_selector, date_selector, statistic, alert):

            stack_composed(path_selector, date_selector, statistic, alert)

        run_process(path_selector, date_selector, statistic, alert)

        # Reactivate button
        btn.activate()

    def field_change(change, date_selector, alert):
        alert.clear()

        months_and_years = get_months_years(w_selector.get_current_path(),
                                            alert)

        if months_and_years:
            years, months = months_and_years
        else:
            # Stop the excecution
            return

        date_selector.clear_season()

        parsed_months = date_selector.numbers_to_months(months)
        date_selector.months_items = parsed_months
        date_selector.years_items = years

    alert = s.Alert()
    btn = s.Btn(text="Calculate statistics")
    out = Output()
    date_selector = DateSelector(season=True, remove_method=['Single date'])

    field_widget = w_selector.widget_field()
    field_widget.observe(
        partial(field_change, date_selector=date_selector, alert=alert),
        'v_model')

    date_tile = date_picker_tile(date_selector)

    w_stats = v.Select(
        label='Statistic',
        items=statistics_io.items,
        v_model=statistics_io.selected,
    )

    link((w_stats, 'items'), (statistics_io, 'items'))
    link((w_stats, 'v_model'), (statistics_io, 'selected'))

    w_cores = v.Slider(v_model=statistics_io.cores,
                       thumb_label='Always',
                       step=1,
                       label='Processors',
                       min=1,
                       max=statistics_io.cores)
    link((w_cores, 'v_model'), (statistics_io, 'cores'))

    w_chunk = v.Slider(v_model=200,
                       thumb_label='Always',
                       step=20,
                       label='Chunk size',
                       max=1000,
                       min=20)
    link((w_chunk, 'v_model'), (statistics_io, 'chunks'))

    advanced_settings = v.ExpansionPanels(
        flat=False,
        children=[
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(children=['Advanced settings']),
                v.ExpansionPanelContent(children=[w_cores, w_chunk])
            ], ),
        ])

    btn.on_event(
        'click',
        partial(
            on_click,
            path_selector=w_selector,
            date_selector=date_selector,
            statistic=statistics_io,
            alert=alert,
            out=out,
        ))

    content = v.Layout(dark=True,
                       _metadata={'mount-id': 'data-input'},
                       class_="pa-5",
                       row=True,
                       align_center=True,
                       children=[
                           v.Flex(xs12=True,
                                  children=[
                                      statistics_text,
                                      v.Subheader(children=['Area selection']),
                                      v.Divider(), w_selector,
                                      v.Subheader(children=['Date selection']),
                                      v.Divider(), date_tile,
                                      v.Divider(), w_stats, advanced_settings,
                                      btn, alert, out
                                  ]),
                       ])

    return content
Ejemplo n.º 9
0
    def __init__(self,
                 schema,
                 out_path=Path("~").expanduser() / "downloads",
                 *args,
                 **kwargs):
        """Custom data table to display classification .csv files with features to create,
        edit or remove rows.

        Args:
            schema (dict): schema (dict {'title':'type'}): Dictionary
                with column names (key) and type of data (value), representing the scheme
                of the table.

            out_path (str) (optional): output path where table will be saved, default to ~/downloads/
        """

        self.out_path = out_path
        self.schema = schema
        self.dialog = Output()

        self.edit_icon = v.Icon(children=["mdi-pencil"])
        edit_icon = sw.Tooltip(self.edit_icon, "Edit selelcted row")

        self.delete_icon = v.Icon(children=["mdi-delete"])
        delete_icon = sw.Tooltip(self.delete_icon,
                                 "Permanently delete the selected row")

        self.add_icon = v.Icon(children=["mdi-plus"])
        add_icon = sw.Tooltip(self.add_icon, "Create a new element")

        self.save_icon = v.Icon(children=["mdi-content-save"])
        save_icon = sw.Tooltip(self.save_icon,
                               "Write current table on SEPAL space")
        self.save_dialog = SaveDialog(table=self,
                                      out_path=self.out_path,
                                      transition=False)

        slot = v.Toolbar(
            class_="d-flex mb-6",
            flat=True,
            children=[
                self.dialog,
                v.ToolbarTitle(children=["Customization tools"]),
                v.Divider(class_="mx-4", inset=True, vertical=True),
                v.Flex(class_="ml-auto",
                       children=[edit_icon, delete_icon, add_icon]),
                v.Divider(class_="mx-4", inset=True, vertical=True),
                save_icon,
            ],
        )

        self.v_slots = [{"name": "top", "variable": "top", "children": [slot]}]

        self.v_model = []
        self.item_key = "id"
        self.show_select = True
        self.single_select = True
        self.hide_default_footer = True

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

        self.edit_icon.on_event("click", self._edit_event)
        self.delete_icon.on_event("click", self._remove_event)
        self.add_icon.on_event("click", self._add_event)
        self.save_icon.on_event("click", self._save_event)
Ejemplo n.º 10
0
    def __init__(self,
                 schema,
                 out_path=Path('~').expanduser() / 'downloads',
                 *args,
                 **kwargs):
        """ Custom data table to display classification .csv files with features to create,
        edit or remove rows.
        
        Args: 
            schema (dict): schema (dict {'title':'type'}): Dictionary 
                with column names (key) and type of data (value), representing the scheme
                of the table.

            out_path (str) (optional): output path where table will be saved, default to ~/downloads/
        """

        self.out_path = out_path
        self.schema = schema
        self.dialog = Output()

        self.edit_icon = v.Icon(children=['mdi-pencil'])
        edit_icon = sw.Tooltip(self.edit_icon, 'Edit selelcted row')

        self.delete_icon = v.Icon(children=['mdi-delete'])
        delete_icon = sw.Tooltip(self.delete_icon,
                                 'Permanently delete the selected row')

        self.add_icon = v.Icon(children=['mdi-plus'])
        add_icon = sw.Tooltip(self.add_icon, 'Create a new element')

        self.save_icon = v.Icon(children=['mdi-content-save'])
        save_icon = sw.Tooltip(self.save_icon,
                               'Write current table on SEPAL space')
        self.save_dialog = SaveDialog(table=self,
                                      out_path=self.out_path,
                                      transition=False)

        slot = v.Toolbar(class_='d-flex mb-6',
                         flat=True,
                         children=[
                             self.dialog,
                             v.ToolbarTitle(children=['Customization tools']),
                             v.Divider(class_='mx-4',
                                       inset=True,
                                       vertical=True),
                             v.Flex(
                                 class_='ml-auto',
                                 children=[edit_icon, delete_icon, add_icon]),
                             v.Divider(class_='mx-4',
                                       inset=True,
                                       vertical=True), save_icon
                         ])

        self.v_slots = [{'name': 'top', 'variable': 'top', 'children': [slot]}]

        self.v_model = []
        self.item_key = 'id'
        self.show_select = True
        self.single_select = True
        self.hide_default_footer = True

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

        self.edit_icon.on_event('click', self._edit_event)
        self.delete_icon.on_event('click', self._remove_event)
        self.add_icon.on_event('click', self._add_event)
        self.save_icon.on_event('click', self._save_event)
Ejemplo n.º 11
0
plant_selection = v.Row(children=[
    v.Col(cols=12, sm=7, md=7, children=[slider_n_plant]),
    v.Col(cols=12, sm=1, md=1, children=[box_n_plant])
])

cb_allplants = v.Checkbox(v_model=False,
                          label="Select all plants",
                          disabled=True)

menu_plant = v.Col(cols=12,
                   sm=3,
                   md=3,
                   children=[
                       files_upload,
                       v.Divider(), files_selection,
                       v.Divider(), genotypes_selection,
                       v.Divider(), plant_selection,
                       v.Divider(), cb_allplants,
                       v.Divider(), parameter_scale,
                       v.Divider(), export_all
                   ])

tableMTG = create_grid()

panel_tableMTG = v.Container(label="The MTG as a table",
                             fluid=True,
                             children=[tableMTG])

graphMTG = create_grid()
Ejemplo n.º 12
0
    def __init__(self, flip_func):

        f = open('app/config.json')
        self.cfg = json.load(f)

        self.output = Output()

        # Colorspace Seletor
        self.colorspace_sel = select(
            items=['RGB', 'HSV', 'LAB', 'GRAY'],
            v_model='RGB',
        )

        # Image Selector
        self.img_selector = select(
            items=self.cfg['images']['images_files'],
            v_model='img_1.jpeg',
            style_='height: 15px',
        )

        # Upload button
        self.upload_btn = button(
            class_='ma-4',
            style_='width:35px; height: 35px',
            size='small',
            fab=True,
            color='primary',
            icon='mdi-upload',
            outlined=True,
        )
        self.f_input = v.FileInput(show_progress=True)

        # Turn Histogram Up Switch
        self.flip_hist_btn = button(
            class_='ma-4',
            style_='width:35px; height: 35px',
            color='primary',
            size='small',
            fab=True,
            icon='mdi-chart-histogram',
            outlined=True,
            on_click=flip_func,
        )

        self.save_op_btn = button(
            class_='ma-4',
            style_='width:35px; height: 35px',
            color='primary',
            size='small',
            fab=True,
            icon='mdi-content-save',
            outlined=True,
            #on_click=flip_func,
        )

        self.github_btn = button(
            class_='ma-4',
            style_='width:35px; height: 35px',
            size='small',
            fab=True,
            color='primary',
            icon='mdi-source-repository',
            outlined=True,
            href='https://github.com/Mateus-M-Reis/grancv',
            target='_blank',
        )

        self.save_chart_btn = button(
            class_='ma-4',
            style_='width:35px; height: 35px',
            size='small',
            fab=True,
            color='secondary',
            icon='mdi-chart-histogram',
            #outlined=True,
        )

        self.save_img_btn = button(
            class_='ma-4',
            style_='width:35px; height: 35px',
            size='small',
            fab=True,
            color='secondary',
            icon='mdi-image-plus',
            #outlined=True,
        )

        self.show_console_btn = button(
            class_='ma-4',
            style_='width:35px; height: 35px',
            size='small',
            fab=True,
            color='secondary',
            icon='mdi-console-line',
            ##outlined=True,
        )

        # Operations Selector
        self.op_selector = select_or_create(
            items=list(self.cfg['operations'].values()),
            v_model='neural-style-transfer',
            multiple=True,
        )
        self.op_selector.on_event('change', self.update_expansion_panel)

        # Operations Panel
        self.op_panel = v.ExpansionPanels(children=[
            smooth_expp, morpho_expp, threshold_expp, nst_expp, watershed_expp
        ], )

        # Sidebar Layout
        self.drawer = v.Card(
            children=[
                v.NavigationDrawer(
                    width='325px',
                    dark=True,
                    color='#FF000000',
                    #expand_on_hover=True,
                    mini_variant_width='75px',
                    fixed=True,  # *
                    floating=True,
                    #permanent=True,
                    #mini_variant=True,
                    #app=True,
                    #disable_route_watcher=True,
                    #disable_resize_watcher=True,
                    #v_model='drawer',
                    #hide_overlay=True,
                    #clipped=True,
                    #absolute=True,
                    #touchless=True,
                    children=[
                        v.List(
                            children=[
                                v.ListItem(children=[
                                    self.upload_btn, self.img_selector
                                ],
                                           class_='d-flex align-stretch mb-6',
                                           style_='height: 40px;'),
                                v.ListItem(children=[
                                    self.flip_hist_btn, self.colorspace_sel
                                ],
                                           class_='d-flex align-stretch mb-6',
                                           style_='height: 40px;'),
                                #v.ListItem(
                                #    children=[
                                #        self.save_op_btn,
                                #        self.save_img_btn,
                                #        self.save_chart_btn,
                                #        self.show_console_btn,
                                #        ],
                                #    class_='d-flex align-stretch mb-6',
                                #    style_='\
                                #            height: 40px; \
                                #            '
                                #    ),
                                v.ListItem(children=[
                                    self.github_btn,
                                    self.op_selector,
                                ],
                                           class_='d-flex align-stretch mb-6',
                                           style_='\
                                            height: 100%; \
                                            '),
                            ],
                            style_='background-color: #000000BF'),
                        v.Divider(),
                        v.List(children=[
                            v.ListItem(children=[
                                self.op_panel,
                            ],
                                       class_='d-flex align-stretch mb-6',
                                       style_='\
                                                width: 100%; \
                                                height: 100%; \
                                                '),
                        ])
                    ])
            ],
            class_='d-flex flex-column mb-12',
        )
Ejemplo n.º 13
0
def dialog_button(label='',
                  icon='mdi-help',
                  _class="icon ma-2",
                  _style="",
                  color="primary",
                  dark=False,
                  dialog_width=600,
                  dialog_title="Dialog Title",
                  dialog_content="Dialog Content",
                ):
    """
    Creates a button and activates a dialog on click

    Useful to display application documentation/help

    Parameters
    ----------
    icon : str (optional, default None)
        Icon to display on button
    label : str (optoinal, default None)
        Text to display on button
    dialog_width : int (optional, default 600)
        Width of the dialog in pixels
    dialog_title : str (optional, default 'Help Title')
        Dialog title
    dialog_content : str (optional, default '')
        Dialog content in markdown format
    color : str (optional, default 'primary')
        Color of button
    dark : bool
        Use dark style
    _class : str (optional, default 'icon ma-2')
        CSS classes of button
    _style: str
        CSS style of button
    """

    if icon is None:
        icon=''

    if label is None:
        label=''

    dialog_button = ipyvuetify.Btn(
        _class_="icon ma-2",
        _style='',
        color=color,
        depressed=True,
        dark=dark,
        children=[label, ipyvuetify.Icon(children=[icon])],
    )

    close_dialog_btn = ipyvuetify.Btn(children=["Close"])

    dialog_dialog = ipyvuetify.Dialog(
        v_model=False,
        scrollable=True,
        width=dialog_width,
        children=[
            ipyvuetify.Card(children=[
                ipyvuetify.CardTitle(class_="headline pa-4",
                                     children=[dialog_title]),
                ipyvuetify.Divider(),
                ipyvuetify.CardText(
                    class_="pa-4 text--primary",
                    primary_title=True,
                    children=[dialog_content],
                ),
                ipyvuetify.Divider(),
                close_dialog_btn,
            ])
        ],
    )

    def open_dialog_dialog(widget, event, data):
        dialog_dialog.v_model = True

    def close_dialog_dialog(widget, event, data):
        dialog_dialog.v_model = False

    display(ipyvuetify.Layout(children=[dialog_dialog]))
    close_dialog_btn.on_event("click", close_dialog_dialog)
    dialog_button.on_event("click", open_dialog_dialog)
    return dialog_button