Ejemplo n.º 1
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')
Ejemplo n.º 2
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)
Ejemplo 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])
        ])
Ejemplo n.º 4
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
Ejemplo n.º 5
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)
Ejemplo n.º 6
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")
Ejemplo n.º 7
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])
            ])
Ejemplo n.º 8
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
Ejemplo n.º 9
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.º 10
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)
    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)
Ejemplo n.º 12
0
               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"}
tabs = v.Tabs(v_model='tab',
              color='grey lighten-5',
              fixed_tabs=True,
              children=tab_children)

app = v.App(style_="background: white",
Ejemplo n.º 13
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)
Ejemplo n.º 14
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)
Ejemplo n.º 15
0
    def vue(self):
        import matplotlib.pyplot as plt
        import matplotlib
        import io
        import base64
        from traitlets import Unicode

        try:
            import ipyvuetify as v
            import ipywidgets as widgets
        except ImportError:
            raise ImportError("Please install ipyvuetify")

        panels = []
        plt.ioff()
        for k in range(self.nschemes):
            myslice = slice(self.stencil.nv_ptr[k], self.stencil.nv_ptr[k + 1])
            P = [sp.latex(p, mode='equation*') for p in self.P[myslice]]
            EQ = [
                sp.latex(eq, mode='equation*')
                for eq in self.EQ_no_swap[myslice]
            ]
            s = [
                sp.latex(s, mode='equation*') for s in self.s_no_swap[myslice]
            ]

            view = self.stencil.visualize(k=k)
            view.fig.canvas.header_visible = False

            panels.append(
                v.ExpansionPanel(children=[
                    v.ExpansionPanelHeader(children=[f'Scheme {k}'],
                                           class_='title'),
                    v.ExpansionPanelContent(children=[
                        v.Card(children=[
                            v.CardTitle(
                                style_='border-bottom: 1px solid black;',
                                children=['Velocities']),
                            v.CardText(children=[
                                v.Row(children=[view.fig.canvas],
                                      justify='center')
                            ]),
                        ],
                               class_="ma-2",
                               elevation=5),
                        v.Card(children=[
                            v.CardTitle(
                                style_='border-bottom: 1px solid black;',
                                children=['Polynomials']),
                            v.CardText(children=[
                                v.Row(children=[widgets.HTMLMath(p)],
                                      justify='center') for p in P
                            ])
                        ],
                               class_="ma-2",
                               elevation=5),
                        v.Card(children=[
                            v.CardTitle(
                                style_='border-bottom: 1px solid black;',
                                children=['Equilibria']),
                            v.CardText(children=[
                                v.Row(children=[widgets.HTMLMath(eq)],
                                      justify='center') for eq in EQ
                            ])
                        ],
                               class_="ma-2",
                               elevation=5),
                        v.Card(children=[
                            v.CardTitle(
                                style_='border-bottom: 1px solid black;',
                                children=['Relaxation parameters']),
                            v.CardText(children=[
                                v.Row(children=[widgets.HTMLMath(s_i)],
                                      justify='center') for s_i in s
                            ])
                        ],
                               class_="ma-2",
                               elevation=5),
                    ])
                ],
                                 class_='ma-2 pa-2'))

        plt.ion()

        panels.append(
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(children=['Moments matrix'],
                                       class_='title'),
                v.ExpansionPanelContent(children=[
                    v.Row(children=[
                        widgets.HTMLMath(
                            f"{sp.latex(self.M_no_swap, mode='equation*')}")
                    ],
                          justify='center')
                ])
            ],
                             class_='ma-2 pa-2'))

        panels.append(
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(children=['Inverse of moments matrix'],
                                       class_='title'),
                v.ExpansionPanelContent(children=[
                    v.Row(children=[
                        widgets.HTMLMath(
                            f"{sp.latex(self.invM_no_swap, mode='equation*')}")
                    ],
                          justify='center')
                ])
            ],
                             class_='ma-2 pa-2'))

        return v.ExpansionPanels(children=panels, multiple=True)
Ejemplo n.º 16
0
        'activator',
        'variable':
        'x',
        'children':
        v.Btn(v_on='x.on',
              color='success',
              dark=True,
              children=['Open dialog']),
    }],
    children=[
        v.Card(children=[
            v.CardTitle(class_='headline gray lighten-2',
                        primary_title=True,
                        children=["Lorem ipsum"]),
            v.CardText(children=[
                lorum_ipsum,
                v.TextField(label='Label', placeholder='Placeholder')
            ]),
        ])
    ])

dialog.on_event('keydown.stop', lambda *args: None)

v.Container(children=[
    v.Row(children=[
        v.Btn(class_='ma-2', color='primary', children=['button']),
        v.Btn(
            class_='ma-2', color='primary', outlined=True, children=['button'
                                                                     ]),
        v.Btn(
            class_='ma-2', color='primary', rounded=True, children=['button']),
        v.Btn(class_='ma-2',
Ejemplo n.º 17
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
Ejemplo n.º 18
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)
Ejemplo n.º 19
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"),
        ]),
Ejemplo n.º 20
0
    def __init__(self, *args, **kwargs):
        with out:
            self.form = self.item_class.form_class(*args, **kwargs)

            create_add = v.Btn(children=['add'], color='success')
            create_close = v.Btn(children=['close'], color='error')

            create_dialog = v.Dialog(
                width='500',
                v_model=False,
                children=[
                    v.Card(children=[
                        v.CardTitle(class_='headline gray lighten-2',
                                    primary_title=True,
                                    children=[self.new_text]),
                        v.CardText(children=[self.form]),
                        v.CardActions(
                            children=[v.Spacer(), create_add, create_close])
                    ]),
                ])

            self.item_list = v.List(children=[])
            add_button = v.Btn(
                children=[v.Icon(children=['mdi-plus']), create_dialog],
                fab=True,
                color='primary',
                small=True,
                dark=True,
            )

            def close_click(widget, event, data):
                create_dialog.v_model = False

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

            def add_click(widget, event, data):
                self.form.check_rules()

                if self.form.v_model:
                    new_item = self.create_item()
                    self.item_list.children.append(new_item)
                    create_dialog.v_model = False

                    def remove_item(widget, event, data):
                        self.item_list.children.remove(new_item)
                        self.item_list.notify_change({
                            'name': 'children',
                            'type': 'change'
                        })

                    new_item.btn.on_event('click', remove_item)
                    new_item.on_event('click', new_item.update_item)
                    new_item.observe(on_change, 'children')

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

            create_close.on_event('click', close_click)
            create_add.on_event('click', add_click)

            def on_add_click(widget, event, data):
                with out:
                    self.form.reset_form()
                    create_dialog.v_model = True

            add_button.on_event('click', on_add_click)

            self.add_button = add_button
            self.widget = v.Card(children=[
                v.CardText(children=[self.item_list]),
                v.CardActions(children=[v.Spacer(), add_button])
            ])
Ejemplo n.º 21
0
    def __init__(self, *args, **kwargs):

        self.class_ = 'pa-4'
        self._metadata = {'mount_id': 'reclassify'}

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

        # Class parameters

        self.root_dir = None
        self.class_path = None
        self.workspace()

        #         self.alert_dialog = Dialog(transition=False)
        self.alert_dialog = sw.Alert().hide()

        title = v.CardTitle(children=[cm.reclassify.title])
        description = v.CardText(
            class_='py-0', children=[sw.Markdown(cm.reclassify.description)])

        self.customize_class = CustomizeTile(self.class_path)
        self.w_class_file = v.Select(label='Select a classes file',
                                     v_model='',
                                     dense=True)

        self.get_table_btn = sw.Btn('Get reclassify table', class_='mb-2')
        self.save_raster_btn = sw.Btn('Reclassify', class_='my-2').hide()

        self.get_items()

        self.w_select_raster = sw.FileInput(['.tif'], label='Search raster')
        self.w_reclassify_table = ReclassifyTable().show()

        tabs_titles = ['Reclassify', 'Customize classification']
        tab_content = [
            v.Card(children=[
                title,
                description,
                self.w_select_raster,
                self.w_class_file,
                self.get_table_btn,
                self.w_reclassify_table,
                self.save_raster_btn,
                self.alert_dialog,
            ]), self.customize_class
        ]

        self.children = [Tabs(tabs_titles, tab_content)]

        # Decorate functions
        self.reclassify_and_save = loading_button(
            self.save_raster_btn, self.alert_dialog)(self.reclassify_and_save)
        self.get_reclassify_table = loading_button(
            self.get_table_btn, self.alert_dialog)(self.get_reclassify_table)

        # Events
        self.get_table_btn.on_event('click', self.get_reclassify_table)
        self.save_raster_btn.on_event('click', self.reclassify_and_save)

        # Refresh tables
        self.customize_class.observe(self.get_items, 'classes_files')
Ejemplo n.º 22
0
    def __init__(self, *args, **kwargs):

        self.class_ = "pa-4"
        self._metadata = {"mount_id": "reclassify"}

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

        # Class parameters

        self.root_dir = None
        self.class_path = None
        self.workspace()

        #         self.alert_dialog = Dialog(transition=False)
        self.alert_dialog = sw.Alert().hide()

        title = v.CardTitle(children=[cm.reclassify.title])
        description = v.CardText(
            class_="py-0", children=[sw.Markdown(cm.reclassify.description)])

        self.customize_class = CustomizeTile(self.class_path)
        self.w_class_file = v.Select(label="Select a classes file",
                                     v_model="",
                                     dense=True)

        self.get_table_btn = sw.Btn("Get reclassify table", class_="mb-2")
        self.save_raster_btn = sw.Btn("Reclassify", class_="my-2").hide()

        self.get_items()

        self.w_select_raster = sw.FileInput([".tif"], label="Search raster")
        self.w_reclassify_table = ReclassifyTable().show()

        tabs_titles = ["Reclassify", "Customize classification"]
        tab_content = [
            v.Card(children=[
                title,
                description,
                self.w_select_raster,
                self.w_class_file,
                self.get_table_btn,
                self.w_reclassify_table,
                self.save_raster_btn,
                self.alert_dialog,
            ]),
            self.customize_class,
        ]

        self.children = [Tabs(tabs_titles, tab_content)]

        # Decorate functions
        self.reclassify_and_save = loading_button(
            self.save_raster_btn, self.alert_dialog)(self.reclassify_and_save)
        self.get_reclassify_table = loading_button(
            self.get_table_btn, self.alert_dialog)(self.get_reclassify_table)

        # Events
        self.get_table_btn.on_event("click", self.get_reclassify_table)
        self.save_raster_btn.on_event("click", self.reclassify_and_save)

        # Refresh tables
        self.customize_class.observe(self.get_items, "classes_files")