Esempio n. 1
0
    def __init__(self,
                 id_,
                 title,
                 inputs=[''],
                 btn=None,
                 alert=None,
                 **kwargs):

        self.btn = btn
        if btn: inputs.append(btn)

        self.alert = alert
        if alert: inputs.append(alert)

        self.title = v.Html(xs12=True, tag='h2', children=[title])

        content = [v.Flex(xs12=True, children=[widget]) for widget in inputs]

        card = v.Card(class_="pa-5",
                      raised=True,
                      xs12=True,
                      children=[self.title] + content)

        super().__init__(_metadata={'mount_id': id_},
                         row=True,
                         align_center=True,
                         class_="ma-5 d-inline",
                         xs12=True,
                         children=[card],
                         **kwargs)
Esempio n. 2
0
    def __init__(self):
        with out:
            yes = v.Btn(children=['yes'],
                        class_='ma-2',
                        style_='width: 100px',
                        color='success')
            no = v.Btn(children=['no'],
                       class_='ma-2',
                       style_='width: 100px',
                       color='error')
            self.width = '500'
            self.v_model = False
            self.text = v.CardTitle(children=[])
            self.children = [
                v.Card(children=[
                    self.text,
                    v.CardActions(children=[v.Spacer(), yes, no])
                ]),
            ]

            self.path = None
            self.replace = True

            yes.on_event('click', self.yes_click)
            no.on_event('click', self.no_click)

            super().__init__()
Esempio n. 3
0
    def __init__(self, states):
        """
        Create a list of state items and a plus button to add new states.

        Parameter
        =========

        states: list
            The list of default states defined by the test case.

        """
        self.states = states
        self.default_state = self.states[0]
        super().__init__(self.default_state)

        self.eval_stab = v.Btn(children=['Check stability'], color='primary')

        for s in states:
            self.item_list.children.append(self.create_item(s))

        self.item_list.notify_change({'name': 'children', 'type': 'change'})

        self.widget = v.Card(children=[
            v.CardTitle(children=['List of linear states', v.Spacer(), self.add_button]),
            v.CardText(children=[self.item_list]),
            v.CardActions(children=[v.Spacer(), self.eval_stab])
        ])
Esempio n. 4
0
    def __init__(self, aoi_tile):

        self.aoi_tile = aoi_tile

        self.title = v.CardTitle(children=['Copy this link to you clipboard'])
        self.text = v.CardText(
            children=["click on the link then 'ctrl+a' and then 'ctrl+c'"])

        self.link = v.TextField(class_="ma-5",
                                v_model='je suis un link',
                                outlined=True,
                                label='link',
                                readonly=True,
                                append_icon='mdi-clipboard-outline')

        self.card = v.Card(children=[
            self.title,
            self.text,
            self.link,
        ])

        super().__init__(value=False, max_width='600px', children=[self.card])

        # self.link.on_event('click', self.select_all)
        self.aoi_tile.aoi_select_btn.observe(self.fire_dialog, 'loading')
Esempio n. 5
0
    def __init__(self, table, **kwargs):
        self.table = table

        update = v.Btn(children=['update'], color='success')
        close = v.Btn(children=['close'], color='error')

        self.form_1d = FormProperties_1D()
        self.form_2d = FormProperties_2D()

        self.form = v.CardText(children=self.form_1d.widget)

        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']), 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. 6
0
class DialogController(AbstrController):
    __layout = v.Dialog(
        width="unset",
        v_model=False,
        children=[
            v.Card(children=[
                v.CardTitle(class_='headline gray lighten-2',
                            primary_title=True,
                            children=[]),
                v.CardText(children=[])
            ])
        ]
    )

    def __init__(self):
        super().__init__("dialog")

    def _get_layout(self):
        return self.__layout

    def show(self, card_title, card_text):
        card = self.__layout.children[0]
        card.children[0].children = [card_title]
        card.children[1].children = [card_text]

        self.__layout.v_model = True

    def hide(self):
        self.__layout.v_model = False
Esempio n. 7
0
    def __init__(self):

        title = v.CardTitle(children=[cm.quintile.clip.title])
        self.link = v.TextField(
            class_="ma-5",
            v_model=None,
            outlined=True,
            label=cm.quintile.clip.lbl,
            hint=cm.quintile.clip.hint,
            persistent_hint=True,
            readonly=True,
            append_icon="mdi-clipboard-outline",
        )

        self.done = v.Btn(color="primary",
                          outlined=True,
                          children=[cm.quintile.clip.done])

        self.card = v.Card(
            children=[title, self.link,
                      v.CardActions(children=[self.done])])

        super().__init__(value=False,
                         persistent=True,
                         max_width="600px",
                         children=[self.card])

        # js links
        self.done.on_event("click", self._done_click)
Esempio n. 8
0
    def __init__(self, state, remove=True, **kwargs):
        """
        Create a state item from the default states defined by the test case
        or by those defined by the user.

        This state item is then added into a v.List and can be clicked to modify
        its values using a dialog box.

        Parameters
        ==========

        state: dict
            the state used to create a state item.

        remove: bool
            add a remove button if yes.

        """
        self.state = state.copy()
        super().__init__(state, **kwargs)

        self.content.children = [f'{self}']

        # add a remove button if state defined by the user
        if remove:
            action = v.ListItemAction(children=[self.btn])
        else:
            action = v.ListItemAction(children=[])

        self.stab_status = v.Card(children=['uncheck'], class_='pa-2')

        self.children=[
            action,
            v.ListItemContent(
            children=[
                v.Card(children=[self.content],
                        flat=True,
                        color='transparent',
                        light=True,
                ),
            self.update_dialog
            ]),
            v.ListItemAction(children=[self.stab_status])
        ]
Esempio n. 9
0
    def __init__(self, *args, **kwargs):
        self.form = self.form_class(*args, **kwargs)

        update_btn = v.Btn(children=['update'], color='success')
        close_btn = v.Btn(children=['close'], color='error')

        self.update_dialog = v.Dialog(
            width='500',
            v_model=False,
            children=[
                v.Card(children=[
                    v.CardTitle(class_='headline gray lighten-2',
                                primary_title=True,
                                children=[self.update_text]),
                    v.CardText(children=[self.form]),
                    v.CardActions(children=[v.Spacer(), update_btn, close_btn])
                ]),
            ])

        update_btn.on_event('click', self.update_click)
        close_btn.on_event('click', self.close_click)

        self.content = v.CardText(children=[f'{self}'])

        self.btn = v.Btn(
            children=[v.Icon(children=['mdi-close'])],
            fab=True,
            color='error',
            dark=True,
            x_small=True,
        )

        super().__init__(children=[
            v.ListItemAction(children=[self.btn]),
            v.ListItemContent(children=[
                v.Card(
                    children=[self.content],
                    flat=True,
                    color='transparent',
                    light=True,
                ), self.update_dialog
            ]),
        ],
                         **kwargs)
Esempio n. 10
0
    def __init__(self, aoi_vew, model):

        # save the model
        self.model = model

        # listen to the aoi_vew to update the map
        self.view = aoi_vew

        self.init_layer = ""
        self.id = ""
        self.index = None

        # add all the standard placeholder, they will be replaced when a layer will be selected
        self.title = v.CardTitle(children=["Layer name"])
        self.text = v.CardText(children=[""])
        self.layer = v.TextField(class_="ma-5",
                                 v_model=None,
                                 color="warning",
                                 outlined=True,
                                 label="Layer")
        self.unit = v.TextField(class_="ma-5",
                                v_model=None,
                                color="warning",
                                outlined=True,
                                label="Unit")

        # add a map to display the layers
        self.m = sm.SepalMap()
        self.m.layout.height = "40vh"
        self.m.layout.margin = "2em"

        # two button will be placed at the bottom of the panel
        self.cancel = sw.Btn(cm.dial.cancel, color="primary", outlined=True)
        self.save = sw.Btn(cm.dial.save, color="primary")

        # create the init card
        self.card = v.Card(children=[
            self.title,
            self.text,
            self.layer,
            self.unit,
            self.m,
            v.CardActions(class_="ma-5", children=[self.cancel, self.save]),
        ])

        # init the dialog
        super().__init__(persistent=True,
                         value=False,
                         max_width="50vw",
                         children=[self.card])

        # js behaviours
        self.layer.on_event("blur", self._on_layer_change)
        self.cancel.on_event("click", self._cancel_click)
        self.save.on_event("click", self._save_click)
        self.view.observe(self._update_aoi, "updated")
Esempio n. 11
0
    def __init__(self, output=None, *args, **kwargs):

        self.output = output if output else Output()

        self.v_model = False
        self.max_width = 436
        self.overlay_color = "black"
        self.overlay_opcity = 0.7
        self.children = [v.Card(children=[self.output])]

        super().__init__(*args, **kwargs)
Esempio n. 12
0
    def vuetify_component(self):
        assert (self._title is not None)

        return v.Card(
            min_width="400px",
            max_width="500px",
            children=[
                v.CardTitle(children=[self._title]),
                v.CardText(
                    children=[self._description, self._component_output])
            ])
Esempio n. 13
0
def backend_widget(backend: Union[IBMQBackend, FakeBackend]) -> None:
    """Display backend information as a widget.

    Args:
        backend: Display information about this backend.
    """
    vue.theme.dark = False
    cred = backend._credentials
    last_tab = vue.TabItem(children=[])
    livedata = LiveDataVisualization()
    card = vue.Card(
        height=600,
        outlined=True,
        children=[
            vue.Toolbar(flat=True,
                        color="#002d9c",
                        children=[
                            vue.ToolbarTitle(children=[
                                '{} @ ({}/{}/{})'.format(
                                    backend.name(), cred.hub, cred.group,
                                    cred.project)
                            ],
                                             style_="color:white")
                        ]),
            vue.Tabs(vertical=True,
                     children=[
                         vue.Tab(children=['Configuration']),
                         vue.Tab(children=['Qubits']),
                         vue.Tab(children=['Non-local Gates']),
                         vue.Tab(children=['Error map']),
                         vue.Tab(children=['Live Data']),
                         vue.Tab(children=['Job Summary']),
                         vue.TabItem(children=[config_tab(backend)]),
                         vue.TabItem(children=[qubits_tab(backend)]),
                         vue.TabItem(children=[gates_tab(backend)]),
                         vue.TabItem(children=[
                             iplot_error_map(
                                 backend, figsize=(None, None), as_widget=True)
                         ]),
                         vue.TabItem(children=[
                             livedata.create_visualization(
                                 backend, figsize=(11, 9), show_title=False)
                         ]), last_tab
                     ])
        ])

    # Load job data async for a bit better performance
    thread = threading.Thread(target=_async_job_loader,
                              args=(last_tab, backend))
    thread.start()

    display(card)
Esempio n. 14
0
    def __init__(self, table, schema, *args, default=None, **kwargs):
        """
        
        Dialog to modify/create new elements from the ClassTable data table
        
        Args: 
            table (ClassTable, v.DataTable): Table linked with dialog
            schema (dict {'title':'type'}): Schema for table showing headers and type of data
            default (dict): Dictionary with default valules
        """

        self.table = table
        self.default = default
        self.title = "New element" if not self.default else "Modify element"
        self.schema = schema
        self.v_model = True
        self.max_width = 500
        self.overlay_opcity = 0.7

        # Action buttons
        self.save = v.Btn(children=['Save'])
        save_tool = sw.Tooltip(self.save, 'Create new element')

        self.cancel = v.Btn(children=['Cancel'])
        cancel_tool = sw.Tooltip(self.cancel, 'Ignore changes')

        self.modify = v.Btn(children=['Modify'])
        modify_tool = sw.Tooltip(self.modify, 'Update row')

        save = [save_tool, cancel_tool]
        modify = [modify_tool, cancel_tool]

        actions = v.CardActions(children=save if not default else modify)

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

        self.children=[
            v.Card(
                class_='pa-4',
                children=[
                    v.CardTitle(children=[self.title])] + \
                    self._get_widgets() + \
                    [actions]
            )
        ]

        # Create events

        self.save.on_event('click', self._save)
        self.modify.on_event('click', self._modify)
        self.cancel.on_event('click', self._cancel)
Esempio n. 15
0
def Tile(id_, title, inputs=[''], btn=None, output=None):
    """ 
    create a customizable tile for the sepal UI framework
    
    Args: 
        id_ (str) : the Id you want to gave to the tile. This Id will be used by the draweritems to show and hide the tile.
        title (str) : the title that will be display on the top of the tile
        btn (v.Btn, optionnal) : if the tile launch a py process, attached a btn to it.
        output( v.Alert, optional) : if you want to display text results of your process add an alert widget to it
        
    Returns: 
        tile (v.Layout) : a fully functionnal tile to be display in an app
    """
    
    if btn:
        inputs.append(btn)
    
    if output:
        inputs.append(output)
        
    
    inputs_widget = v.Layout(
        _metadata={'mount-id': '{}-data-input'.format(id_)},
        row=True,
        class_="pa-5",
        align_center=True, 
        children=[v.Flex(xs12=True, children=[widget]) for widget in inputs]
    )
    
    tile = v.Layout(
        _metadata={'mount_id': id_},
        row=True,
        xs12=True,
        align_center=True, 
        class_="ma-5 d-inline",
        children=[
            v.Card( 
                class_="pa-5",
                raised=True,
                xs12=True,
                children=[
                    v.Html(xs12=True, tag='h2', children=[title]),
                    v.Flex(xs12=True, children=[inputs_widget]),   
                ]
            )
        ]
    )
    
    return tile
Esempio n. 16
0
def exception_widget(exc):
    """Create an exception notification widget and raises
    sys.exit() silently.

    Parameters:
        exc (Exception): Input exception.

    Raises:
        SilentExit: Exits silently.
    """
    tback = traceback.TracebackException.from_exception(exc).format()
    trace_list = [string for string in tback if 'File' in string]
    if any(trace_list):
        tback = trace_list[-1].split('\n')[0]
    else:
        tback = ''
    exc_type = exc.__class__.__name__
    exc_msg = exc.args[0]

    title = vue.CardTitle(class_='headline body-1 font-weight-medium',
                          primary_title=True,
                          children=[
                              vue.Icon(children=['warning'],
                                       style_='color:#ffffff;'
                                       'margin: 0px 5px'), exc_type
                          ],
                          style_='height:35px;'
                          'background-color:#AA0114;'
                          'color:#ffffff;'
                          'padding: 0px 10px')
    subtitle = vue.CardSubtitle(
        children=[exc_msg],
        class_='text--primary body-1 fontweight-medium',
        style_="margin: 0px 0px; color:#212121")
    children = [title, subtitle]

    if tback:
        text = vue.CardText(children=[tback],
                            class_='font-weight-medium',
                            style_="margin: -15px 0px")
        children.append(text)

    exc_card = vue.Card(
        children=children,
        style_='height: auto; min-height: 100px;',
    )
    display(exc_card)
    raise SilentExit
Esempio n. 17
0
    def __init__(self, table, out_path, *args, **kwargs):
        """

        Dialog to save as .csv file the content of a ClassTable data table

        Args:
            table (ClassTable, v.DataTable): Table linked with dialog
            out_path (str): Folder path to store table content
        """
        self.max_width = 500
        self.v_model = False
        self.out_path = out_path

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

        self.table = table

        self.w_file_name = v.TextField(label="Insert output file name",
                                       type="string",
                                       v_model="new_table.csv")

        # Action buttons
        self.save = v.Btn(children=["Save"])
        save = sw.Tooltip(self.save, "Save table")

        self.cancel = v.Btn(children=["Cancel"])
        cancel = sw.Tooltip(self.cancel, "Cancel")

        info = (sw.Alert().add_msg("The table will be stored in {}".format(
            str(out_path))).show())

        self.children = [
            v.Card(
                class_="pa-4",
                children=[
                    v.CardTitle(children=["Save table"]),
                    self.w_file_name,
                    info,
                    save,
                    cancel,
                ],
            )
        ]

        # Create events
        self.save.on_event("click", self._save)
        self.cancel.on_event("click", self._cancel)
def backend_widget(backend):
    """Display backend information as a widget.

    Parameters:
        backend (IBMQBackend): A backend.
    """
    cred = backend.provider().credentials
    last_tab = vue.TabItem(children=[])
    card = vue.Card(
        height=600,
        outlined=True,
        children=[
            vue.Toolbar(flat=True,
                        color="#002d9c",
                        children=[
                            vue.ToolbarTitle(children=[
                                '{} @ ({}/{}/{})'.format(
                                    backend.name(), cred.hub, cred.group,
                                    cred.project)
                            ],
                                             style_="color:white")
                        ]),
            vue.Tabs(
                vertical=True,
                children=[
                    vue.Tab(children=['Configuration']),
                    vue.Tab(children=['Qubits']),
                    vue.Tab(children=['Multi-Qubit Gates']),
                    vue.Tab(children=['Error map']),
                    vue.Tab(children=['Job Summary']),
                    vue.TabItem(children=[config_tab(backend)]),
                    vue.TabItem(children=[qubits_tab(backend)]),
                    vue.TabItem(children=[gates_tab(backend)]),
                    vue.TabItem(
                        children=[iplot_error_map(backend, as_widget=True)]),
                    last_tab
                ])
        ])

    # Load job data async for a bit better performance
    thread = threading.Thread(target=_async_job_loader,
                              args=(last_tab, backend))
    thread.start()

    display(card)
Esempio n. 19
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)
Esempio n. 20
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. 21
0
    def __init__(self, table, out_path, *args, **kwargs):
        """
        
        Dialog to save as .csv file the content of a ClassTable data table
        
        Args: 
            table (ClassTable, v.DataTable): Table linked with dialog
            out_path (str): Folder path to store table content
        """
        self.max_width = 500
        self.v_model = False
        self.out_path = out_path

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

        self.table = table

        self.w_file_name = v.TextField(label='Insert output file name',
                                       type='string',
                                       v_model='new_table.csv')

        # Action buttons
        self.save = v.Btn(children=['Save'])
        save = sw.Tooltip(self.save, 'Save table')

        self.cancel = v.Btn(children=['Cancel'])
        cancel = sw.Tooltip(self.cancel, 'Cancel')

        info = sw.Alert().add_msg('The table will be stored in {}'.format(
            str(out_path))).show()

        self.children = [
            v.Card(class_='pa-4',
                   children=[
                       v.CardTitle(children=['Save table']), self.w_file_name,
                       info, save, cancel
                   ])
        ]

        # Create events
        self.save.on_event('click', self._save)
        self.cancel.on_event('click', self._cancel)
Esempio n. 22
0
def get_information(tab_id, mc, tc, lb):
    if tab_id == 0:
        return []

    items = [
        v.ListItem(children=[
            v.ListItemContent(children=[
                f"{mc.select_category.v_model}: " + f"{mc.select_model.v_model}"
            ],
            class_='px-4 py-0'
            )
        ],
        class_='mb-0'),
        v.ListItem(children=[
            v.ListItemContent(children=[
                f"Test case: {tc.select_case.v_model}"
            ],
            class_='px-4 py-0',
            )
        ],
        class_='mb-0'),
        v.ListItem(children=[
            v.ListItemContent(children=[
                f"Scheme: {lb.select_case.v_model}"
            ],
            class_='px-4 py-0',
            )
        ],
        class_='mb-0'),
    ]

    return [
        v.Card(children=[
            v.CardTitle(children=['Information'], class_='pb-1'),
            v.List(children=items[0:min(tab_id, 3)],
            dense=True,
            class_='pa-0')
        ])
    ]
Esempio n. 23
0
        def create_zip(widget, event, data):
            from zipfile import ZipFile

            zipfilename = os.path.join(voila_notebook, 'results.zip')
            with ZipFile(zipfilename, 'w') as zipObj:
                for folderName, subfolders, filenames in os.walk(default_path):
                    for filename in filenames:
                        #create complete filepath of file in directory
                        filePath = os.path.join(folderName, filename)

                        # Add file to zip
                        zipObj.write(filePath,
                                     filePath.replace(default_path, ''))

            dialog.children = [
                v.Card(children=[
                    v.CardTitle(children=[
                        widgets.HTML(
                            f'<a href="./results.zip" download="results.zip">Download the archive</a>'
                        )
                    ])
                ])
            ]
            dialog.v_model = True
    def __init__(self):

        self.feature = None

        self.w_name = v.TextField(label=cm.map.dialog.label, v_model=None)

        self.btn = sw.Btn(cm.map.dialog.btn, "mdi-check")

        card = v.Card(
            class_="ma-5",
            children=[
                v.CardTitle(children=[cm.map.dialog.title]),
                v.CardText(children=[self.w_name]),
                v.CardActions(children=[self.btn]),
            ],
        )

        # init the dialog
        super().__init__(
            persistent=True, value=False, max_width="700px", children=[card]
        )

        # add js behavior
        self.btn.on_event("click", self._on_click)
Esempio n. 25
0
tab_children = []

for stage in sorted(filelist.keys()):
    items = filelist[stage]
    cards = [
        v.Flex(ma_2=True,
               fluid=True,
               children=[
                   v.Card(hover=True,
                          align_center=True,
                          fluid=True,
                          min_width='300px',
                          max_width='300px',
                          href=details['link'],
                          target='_blank',
                          children=[
                              v.CardTitle(children=[
                                  v.Html(tag='div',
                                         class_='headline mb-0',
                                         children=[details['title']]),
                                  v.Spacer(),
                              ]),
                              v.CardText(children=[details['description']]),
                          ])
               ]) for i, details in enumerate(items)
    ]

    tab_children.append(v.Tab(children=[stage]))
    tab_children.append(
        v.TabItem(children=[v.Layout(ma_5=True, wrap=True, children=cards)]))

# + {"Collapsed": "false"}
Esempio n. 26
0
    def __init__(self):

        # init the downloadable informations
        self.geometry = None
        self.dataset = None
        self.name = None
        self.aoi_name = None

        # create the useful widgets
        self.w_scale = v.Slider(
            v_model=30,  # align on the landsat images
            min=10,
            max=300,
            thumb_label=True,
            step=10,
        )

        self.w_method = v.RadioGroup(
            v_model="gee",
            row=True,
            children=[
                v.Radio(label=cm.export.radio.sepal, value="sepal"),
                v.Radio(label=cm.export.radio.gee, value="gee"),
            ],
        )

        self.alert = sw.Alert()

        self.btn = sw.Btn(cm.export.apply, small=True)

        export_data = v.Card(children=[
            v.CardTitle(
                children=[v.Html(tag="h4", children=[cm.export.title])]),
            v.CardText(children=[
                v.Html(tag="h4", children=[cm.export.scale]),
                self.w_scale,
                v.Html(tag="h4", children=[cm.export.radio.label]),
                self.w_method,
                self.alert,
            ]),
            v.CardActions(children=[self.btn]),
        ])

        # the clickable icon
        self.download_btn = v.Btn(
            v_on="menu.on",
            color="primary",
            icon=True,
            children=[v.Icon(children=["mdi-cloud-download"])],
        )

        super().__init__(
            value=False,
            close_on_content_click=False,
            nudge_width=200,
            offset_x=True,
            children=[export_data],
            v_slots=[{
                "name": "activator",
                "variable": "menu",
                "children": self.download_btn
            }],
        )

        # add js behaviour
        self.btn.on_event("click", self._apply)
Esempio n. 27
0
    def __init__(self, test_case_widget, lb_scheme_widget):
        """
        Widget definition for linear stability of a lattice Boltzmann scheme.

        Parameters
        ==========

        - test_case_widget:
            widget of the test case (see test_case.py).

        - lb_scheme_widget:
            widget of the lattice Boltzmann scheme (see lb_scheme.py).

        This widget is composed by a menu where you can modify the parameters of the
        lattice Boltzmann scheme.

        This widget is also composed by a main widget where the linear stability for the
        states provided by the test case can be tested to check their stability. A user can
        add its own states. A second tab allows to plot the stability region of a given state.

        """
        self.test_case_widget = test_case_widget
        self.lb_scheme_widget = lb_scheme_widget

        ##
        ## The menu
        ##
        self.menu = [self.lb_scheme_widget.panels]

        ##
        ## The main
        ##

        # Tab 1
        test_case = self.test_case_widget.get_case()
        self.state_widget = StateWidget(test_case.state())
        tab1 = v.TabItem(children=[self.state_widget.widget],
                         class_="ma-6")

        # Tab 2
        self.state_list = v.Select(label='States', items=[], v_model=0)

        plot_stab = v.Btn(children=['Plot stability region'], color='primary')
        self.alert = v.Alert(children=['Check the stability for this state...'], dense=True, type='info')
        self.stab_output, self.markers1, self.markers2 = prepare_stab_plot()

        self.container = Container(children=[v.Row(children=[v.Col(children=[self.alert])]),
                                             v.Row(children=[self.stab_output.canvas], align='center', justify='center')],
                                   align_content_center=True,)
        self.container.hide()

        tab2 = v.TabItem(children=[
            v.Card(children=[
                v.CardTitle(children=['Plot the linear stability for a given state']),
                v.CardText(children=[
                    v.Row(children=[
                        v.Col(children=[self.state_list], md=9, sm=12),
                        v.Col(children=[plot_stab], md=3, sm=12),
                        ],
                        align='center',
                        justify='space-around'
                    ),
                    self.container
                ]),
            ],
            class_="ma-6",
            )]
        )

        # main
        tabs = v.Tabs(v_model=None,
                      children=[v.Tab(children=['Check stability']),
                                v.Tab(children=['Plot stability region']),
                                tab1,
                                tab2
                      ])

        self.main = [tabs]

        self.update_states(None)
        self.change_test_case(None)

        ##
        ## Widget events
        ##
        self.test_case_widget.select_case.observe(self.change_test_case, 'v_model')
        self.test_case_widget.select_case.observe(self.hide_plot, 'v_model')
        self.lb_scheme_widget.select_case.observe(self.hide_plot, 'v_model')

        self.state_widget.eval_stab.on_event('click', self.stability_states)
        self.state_widget.item_list.observe(self.update_states, 'children')

        plot_stab.on_event('click', self.plot_stability)
Esempio n. 28
0
menu_plant_extraction = v.Col(
    cols=12,
    sm=3,
    md=3,
    children=[genotypes_selection_extraction, export_extraction])

df_modulescale = create_grid()

panel_df = v.Container(fluid=True, children=[df_modulescale])

df_description = create_grid()

panel_description = v.Container(fluid=True, children=[df_description])

tab_extraction_content = v.Row(children=[
    v.Card(style_=layout_card, children=[info.p4_doc_extraction]),
    v.Col(cols=12,
          sm=12,
          md=12,
          children=[
              menu_plant_extraction,
              panel_df,
              panel_description,
          ]),
])

genotypes_selection_single_genotype = v.Select(items=[],
                                               chips=True,
                                               multiple=False,
                                               v_model="",
                                               label="Select Genotype",
Esempio n. 29
0
    def __init__(self):

        # init the downloadable informations
        self.geometry = None
        self.names = []
        self.datasets = {}

        # create the useful widgets
        self.w_scale = v.Slider(
            class_="mt-5",
            v_model=30,  # align on the landsat images,
            ticks="always",
            tick_labels=[
                str(i) if i in self.TICKS_TO_SHOW else ""
                for i in range(10, 301, 10)
            ],
            min=10,
            max=300,
            thumb_label=True,
            step=10,
        )

        self.w_prefix = v.TextField(
            label=cm.export.name,
            small=True,
            dense=True,
            v_model=None,
        )

        self.w_datasets = v.Select(
            dense=True,
            small=True,
            label=cm.export.datasets,
            v_model=None,
            items=[*self.datasets],
            multiple=True,
            chips=True,
        )

        self.w_method = v.RadioGroup(
            v_model="gee",
            row=True,
            children=[
                v.Radio(label=cm.export.radio.sepal, value="sepal"),
                v.Radio(label=cm.export.radio.gee, value="gee"),
            ],
        )

        self.alert = sw.Alert()

        self.btn = sw.Btn(cm.export.apply, small=True)

        export_data = v.Card(children=[
            v.CardTitle(
                children=[v.Html(tag="h4", children=[cm.export.title])]),
            v.CardText(children=[
                self.w_prefix,
                self.w_datasets,
                v.Html(tag="h4", children=[cm.export.scale]),
                self.w_scale,
                v.Html(tag="h4", children=[cm.export.radio.label]),
                self.w_method,
                self.alert,
            ]),
            v.CardActions(children=[self.btn]),
        ])

        # the clickable icon
        self.w_down = v.Btn(
            v_on="menu.on",
            color="primary",
            icon=True,
            children=[v.Icon(children=["mdi-cloud-download"])],
        )

        super().__init__(
            value=False,
            close_on_content_click=False,
            nudge_width=200,
            offset_x=True,
            children=[export_data],
            v_slots=[{
                "name": "activator",
                "variable": "menu",
                "children": self.w_down
            }],
        )

        # add js behaviour
        self.btn.on_event("click", self._apply)
Esempio n. 30
0
    def __init__(self, test_case_widget, lb_scheme_widget):
        self.test_case_widget = test_case_widget
        self.lb_scheme_widget = lb_scheme_widget

        test_case = test_case_widget.get_case()
        lb_param = lb_scheme_widget.parameters
        tc_param = test_case_widget.parameters

        dx = default_dx
        nx = int(test_case.size()[0]/dx) + 1
        ny = 1
        dt = dx/lb_param['la'].value
        nt = int(test_case.duration/dt)

        self.discret = {
            'nx': NbPointsField(label='Number of points in x', v_model=nx, disabled=True),
            'ny': NbPointsField(label='Number of points in y', v_model=ny, disabled=True, class_='d-none'),
            'dx': StrictlyPositiveFloatField(label='Space step', v_model=dx),
            'nt': StrictlyPositiveIntField(label='Number of steps', v_model=nt, disable=True),
            'dt': StrictlyPositiveFloatField(label='Time step', v_model=dt),
        }
        self.la_vue = v.CardText(children=[lb_param['la']])

        for value in self.discret.values():
            value.observe(self.observer, 'v_model')

        lb_param['la'].observe(self.observer, 'v_model')

        tc_param['xmin'].observe(self.observer, 'v_model')
        tc_param['xmax'].observe(self.observer, 'v_model')
        if test_case_widget.get_case().dim > 1:
            tc_param['ymin'].observe(self.observer, 'v_model')
            tc_param['ymax'].observe(self.observer, 'v_model')

        test_case_widget.select_case.observe(self.change_test_case, 'v_model')
        lb_scheme_widget.select_case.observe(self.change_test_case, 'v_model')

        super().__init__(children=[
            v.ExpansionPanelHeader(children=['Discretization']),
            v.ExpansionPanelContent(children=[
                v.Card(children=[
                    v.CardTitle(children=['In space']),
                    v.CardText(children=[
                        self.discret['nx'],
                        self.discret['ny'],
                        self.discret['dx'],
                    ]),
                ], class_="ma-1"),
                v.Card(children=[
                    v.CardTitle(children=['In time']),
                    v.CardText(children=[
                        self.discret['nt'],
                        self.discret['dt'],
                    ]),
                ], class_="ma-1"),
                v.Card(children=[
                    v.CardTitle(children=['Scheme velocity']),
                    self.la_vue,
                ], class_="ma-1"),
            ], class_="px-1"),
        ]),