コード例 #1
0
    def __init__(self, model):

        # create inputs
        radius_title = v.Html(tag="h4",
                              class_="mt-5",
                              children=[cm.input_lbl.self_ref])
        radius = v.Slider(
            class_="mt-5",
            label=cm.input_lbl.kernel_radius,
            max=cp.max_kernel_radius,
            step=10,
            v_model=model.kernel_radius,
            thumb_label="always",
        )
        ddr_title = v.Html(tag="h4", children=[cm.input_lbl.ddr])
        threshold = v.Slider(
            class_="mt-5",
            label=cm.input_lbl.filter_threshold,
            v_model=model.filter_threshod,
            step=0.001,
            max=0.1,
            thumb_label="always",
        )
        filtering_radius = v.Slider(
            class_="mt-5",
            label=cm.input_lbl.filter_radius,
            min=cp.min_radius_filtering_kernel,
            max=cp.max_radius_filtering_kernel,
            v_model=model.filter_radius,
            step=10,
            thumb_label="always",
        )
        cleaning = v.Slider(
            class_="mt-5",
            label=cm.input_lbl.disturbance_event,
            max=cp.max_disturbing_event_per_kernel,
            v_model=model.cleaning_offset,
            thumb_label="always",
        )

        # bind to the io object
        model.bind(radius,
                   "kernel_radius").bind(threshold, "filter_threshod").bind(
                       filtering_radius,
                       "filter_radius").bind(cleaning, "cleaning_offset")

        super().__init__(
            "nested_widget",
            cm.tile.fcdm,
            inputs=[
                radius_title,
                radius,
                ddr_title,
                threshold,
                filtering_radius,
                cleaning,
            ],
        )
コード例 #2
0
    def __init__(self, aoi_model, model, viz_tile, export_tile, **kwargs):

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

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

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

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

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

        # now that the Tile is created we can link it to a specific function
        self.btn.on_event("click", self._on_run)
コード例 #3
0
    def add_live_msg(self, msg, type_='info'):

        current_time = datetime.now().strftime("%Y/%m/%d, %H:%M:%S")

        self.show()
        self.type = type_ if (type_ in self.TYPES) else self.TYPES[0]

        self.children = [
            v.Html(tag='p', children=['[{}]'.format(current_time)]),
            v.Html(tag='p', children=[msg])
        ]

        return self
コード例 #4
0
ファイル: date_slider.py プロジェクト: 12rambau/bfast_gpu
    def __init__(self, dates=None, **kwargs):

        # display the dates in a text filed in a the prepend slot
        self.display = v.Html(tag="span", children=[""])

        # create a range widget with the default params
        self.slider = v.Slider(class_="pl-5 pr-1 mt-1")

        # add the non conventional parameters for customization
        for k, val in kwargs.items():
            if hasattr(self.slider, k):
                setattr(self.slider, k, val)

        # wrap everything in a layout
        super().__init__(
            row=True,
            v_model=None,
            xs12=True,
            children=[
                v.Flex(xs10=True, children=[self.slider]),
                v.Flex(xs2=True, children=[self.display]),
            ],
        )

        # link the v_models
        self.slider.observe(self._on_change, "v_model")

        # add the real dates if existing
        if dates:
            self.set_dates(dates)
        else:
            self.disable()
コード例 #5
0
ファイル: windows.py プロジェクト: vogtpet/gwb
    def __init__(self, label="Thresholds"):

        # hidden textfield to save the v_model
        # the v_model will be stored as json
        self.save = v.TextField(v_model=None)

        # create the inputs
        self.text_fields = [
            v.TextField(placeholder=cm.frag.window_lbl.format(i + 1),
                        v_model=None,
                        type="number",
                        class_='ml-1 mr-1',
                        hint=cm.frag.invalid_window) for i in range(10)
        ]

        # title
        title = v.Html(tag='h4', children=[label])

        # add js behaviour
        for w in self.text_fields:
            w.observe(self._on_change, 'v_model')
            w.on_event('focusout', self._on_focusout)

        super().__init__(
            class_="ma-5",
            row=True,
            children=[title,
                      v.Layout(row=True, children=self.text_fields)])
コード例 #6
0
    def set_title(self, title):

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

        self.children[0].children = [title] + self.children[0].children[1:]

        return self
コード例 #7
0
def construct_selects_container(selects_meta: dict, title=None):
    """
    Constructs a group of selector dropdowns
    
    Accepts:
        - selects_meta: dict
            Mapping from the select labels to their respective 
            lists from which the selection will be pre-populated
        - title: str
            Label which will be added as a p tag at the top of
            the section container
            
    Returns:
        - selects_container
            Container object with each select as a child
    
    """

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

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

    selects_container = v.Container(children=selects_list)

    return selects_container
コード例 #8
0
def df_items_to_tooltip(df, text_key: str, tool_tip_key: str):
    """
    Turns df into dictionary with rows as lists items and 
    passes specified keys to item text and tooltip respectively.
    Returns:
        list of rows with containers with text and tooltips 
    """

    df_dict = df.to_dict(orient="records")

    row_conts = []

    for row in df_dict:
        container = v.Container(children=[
            v.Tooltip(
                bottom=True,
                v_slots=[{
                    "name":
                    "activator",
                    "variable":
                    "tooltip",
                    "children":
                    v.Html(
                        tag="t2",
                        v_on="tooltip.on",
                        children=[str(row[text_key])],
                    ),
                }],
                children=[str(row[tool_tip_key])],
            )
        ])

        row_conts.append(field)

    return row_conts
コード例 #9
0
    def __init__(self, label="Thresholds"):

        # hidden textfield to save the v_model
        # the v_model will be stored as json
        self.save = v.TextField(v_model=None)

        # create the inputs
        self.text_fields = [
            v.TextField(placeholder=f'threshold {i+1}',
                        v_model=None,
                        type="number",
                        class_='ml-1 mr-1',
                        hint=cm.acc.res_hint) for i in range(5)
        ]

        # title
        title = v.Html(tag='h4', children=[label])

        for w in self.text_fields:
            w.observe(self._on_change, 'v_model')
            w.on_event('focusout', self._on_focus_out)

        super().__init__(
            class_="ma-5",
            row=True,
            children=[title,
                      v.Layout(row=True, children=self.text_fields)])
コード例 #10
0
ファイル: legend.py プロジェクト: NVSL/CSE141pp-Tool-Moneta
    def __init__(self, model):
        self.model = model

        self.panels = v.ExpansionPanels(accordion=True, multiple=True, v_model=[])
        up = 'keyboard_arrow_up'
        down = 'keyboard_arrow_down'
        legend_icon = v.Icon(children=[down])
        self.legend_button = v.Btn(icon=True, children=[legend_icon])
        # Style to remove gray background in panels, and remove padding in panel contents
        panel_style = v.Html(tag='style', children=[(
            ".v-application--wrap{background-color: white!important}"
            ".v-expansion-panel-content__wrap{padding:0!important}"
            ".v-input__slot .v-label{color: black!important}"
        )])

        def a(): self.widgets = VBox([self.panels, panel_style], layout=Layout(padding='0px', border='1px solid black', width='400px'))
        def b(): self.accesses = Accesses(model, self.update_selection)
        def c(): self.stats = PlotStats(model)
        def d(): self.tags = Tags(model, self.update_selection, tag_type=TAG_TYPE_SPACETIME)
        def e(): self.threads = Tags(model, self.update_selection, tag_type=TAG_TYPE_THREAD)
        def m(): self.mearsurement = PlotMeasure(model)
        def f(): self.add_panel(LEGEND_MEM_ACCESS_TITLE, self.accesses.widgets)
        def g(): self.add_panel(LEGEND_TAGS_TITLE, self.tags.widgets)
        def h(): self.add_panel(LEGEND_THREADS_TITLE, self.threads.widgets)
        #def i(): self.add_panel(LEGEND_STATS_TITLE, self.stats.widgets)
        def n(): self.add_panel(LEGEND_MEASUREMENT_TITLE, self.mearsurement.widgets)

        self.progress_bar([
            a,
            b,
            c,
            d,
            e,
            m,
            f,
            g,
            h,
            #i,
            n
            ])

        # give accesses nformation about tags and threads for layers



        def update_legend_icon(_panels, _, selected):
            if len(selected) == len(self.panels.children):
                legend_icon.children = [up]
            elif selected == []:
                legend_icon.children = [down]
        self.panels.on_event('change', update_legend_icon)

        def update_panels(*args):
            if legend_icon.children[0] == up:
                legend_icon.children = [down]
                self.panels.v_model = []
            else:
                legend_icon.children = [up]
                self.panels.v_model = list(range(len(self.panels.children)))
        self.legend_button.on_event('click', update_panels)
コード例 #11
0
ファイル: tile.py プロジェクト: 12rambau/sepal_ui
    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)
コード例 #12
0
    def __init__(self, dates=None, **kwargs):

        # save the dates values
        self.dates = dates

        # display the dates in a text filed in a the prepend slot
        self.display = v.Html(tag="span", children=[""])

        # create a range widget with the default params
        self.range = v.RangeSlider(disabled=True,
                                   v_model=[0, 1],
                                   max=1,
                                   class_="pl-5 pr-1 mt-1")

        # add the non conventional parameters for customization
        for k, val in kwargs.items():
            if hasattr(self.range, k):
                setattr(self.range, k, val)

        # wrap everything in a layout
        super().__init__(row=True,
                         v_model=None,
                         xs12=True,
                         children=[
                             v.Flex(xs9=True, children=[self.range]),
                             v.Flex(xs3=True, children=[self.display])
                         ])

        # link the v_models
        self.range.observe(self._on_change, 'v_model')

        # add the dates if existing
        if dates:
            self.set_dates(dates)
コード例 #13
0
def displayIO(widget_alert, message, alert_type='info'):
    """ Display the message in a vuetify alert DOM object with specific coloring
    Args: 
        widget_alert (v.Alert) : the vuetify alert to modify
        alert_type (str) : the alert color
        message (v.Children) : a DOM element or a string to fill the message 
    """

    list_color = ['info', 'success', 'warning', 'error']
    if not alert_type in list_color:
        alert_type = 'info'

    widget_alert.type = alert_type

    current_time = datetime.now().strftime("%Y/%m/%d, %H:%M:%S")
    widget_alert.children = [
        v.Html(tag='p', children=['[{0}]'.format(current_time)]),
        v.Html(tag='p', children=[message])
    ]
コード例 #14
0
ファイル: vuetify_layout.py プロジェクト: sk1p/glue-jupyter
def vuetify_layout_factory(viewer):
    def on_click(widget, event, data):
        drawer.v_model = not drawer.v_model

    sidebar_button = v.AppBarNavIcon()
    sidebar_button.on_event('click', on_click)

    options_panel = v.ExpansionPanels(
        v_model=[0, 1],
        multiple=True,
        accordion=True,
        style_='padding-left: 1px; min-width: 200px',
        children=[
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(class_='font-weight-bold',
                                       children=['Viewer Options']),
                v.ExpansionPanelContent(children=[viewer.viewer_options])
            ]),
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(class_='font-weight-bold',
                                       children=['Layer Options']),
                v.ExpansionPanelContent(children=[viewer.layer_options])
            ])
        ])

    drawer = v.NavigationDrawer(v_model=False,
                                absolute=True,
                                right=True,
                                children=[sidebar_button, options_panel],
                                width="min-content")

    toolbar = v.Toolbar(
        dense=True,
        class_='elevation-0',
        children=[
            v.ToolbarItems(children=[
                viewer.toolbar_selection_tools, viewer.toolbar_selection_mode,
                viewer.toolbar_active_subset
            ]),
            v.Spacer(), sidebar_button
        ])

    layout = v.Html(tag='div',
                    children=[
                        toolbar,
                        v.Row(no_gutters=True,
                              children=[
                                  v.Col(cols=12,
                                        children=[viewer.figure_widget]),
                                  v.Col(cols=12,
                                        children=[viewer.output_widget])
                              ]), drawer
                    ])

    return layout
コード例 #15
0
def vuetify_layout_factory(viewer):

    def on_click(widget, event, data):
        drawer.v_model = not drawer.v_model

    sidebar_button = v.AppBarNavIcon()
    sidebar_button.on_event('click', on_click)

    options_panel = v.ExpansionPanels(
        v_model=[0, 1], multiple=True, accordion=True, style_='padding-left: 1px',
        children=[
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(class_='font-weight-bold', children=['Viewer Options']),
                v.ExpansionPanelContent(children=[viewer.viewer_options])]),
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(class_='font-weight-bold', children=['Layer Options']),
                v.ExpansionPanelContent(children=[viewer.layer_options])])])

    drawer = v.NavigationDrawer(v_model=False, absolute=True, right=True,
                                children=[sidebar_button,
                                          options_panel], width="min-content")

    toolbar_selection_tools = BasicJupyterToolbar(viewer)

    tool_ids, subtool_ids = get_viewer_tools(viewer.__class__)

    if subtool_ids:
        raise ValueError('subtools are not yet supported in Jupyter viewers')

    for tool_id in tool_ids:
        mode_cls = viewer_tool.members[tool_id]
        mode = mode_cls(viewer)
        toolbar_selection_tools.add_tool(mode)

    toolbar_active_subset = SubsetSelect(viewer)

    toolbar_selection_mode = SelectionModeMenu(viewer)

    toolbar = v.Toolbar(dense=True, class_='elevation-0',
                        children=[v.ToolbarItems(children=[toolbar_selection_tools,
                                                           toolbar_selection_mode,
                                                           toolbar_active_subset]),
                                  v.Spacer(),
                                  sidebar_button])

    layout = v.Html(tag='div', children=[
        toolbar,
        v.Row(no_gutters=True, children=[
            v.Col(cols=12, children=[viewer.figure_widget]),
            v.Col(cols=12, children=[viewer.output_widget])
        ]),
        drawer
    ])

    return layout
コード例 #16
0
    def update_progress(self, progress, msg='Progress', bar_length=30):
        """
        Update the Alert message with a progress bar. This function will stay until we manage to use tqdm in the widgets
        
        Args:
            progress (float): the progress status in float [0, 1]
            msg (str, optionnal): The message to use before the progress bar 
            bar_length (int, optionnal): the length of the progress bar in characters 
            
        Return:
            self
        """

        # define the characters to use in the progress bar
        plain_char = '█'
        empty_char = ' '

        # cast the progress to float
        progress = float(progress)

        # set the length parameter
        block = int(round(bar_length * progress))

        # construct the message content
        text = f'|{plain_char * block + empty_char * (bar_length - block)}|'

        # add the message to the output
        self.add_live_msg(
            v.Html(tag='span',
                   children=[
                       v.Html(tag='span',
                              children=[f'{msg}: '],
                              class_='d-inline'),
                       v.Html(tag='pre',
                              class_='info--text d-inline',
                              children=[text]),
                       v.Html(tag='span',
                              children=[f' {progress *100:.1f}%'],
                              class_='d-inline')
                   ]))

        return self
コード例 #17
0
ファイル: model_class.py プロジェクト: PeterDezy/FAST-OAD
    def __init__(self, name):

        # Name of the model
        self.name = name

        # Widget TextField to change the name of the model
        self.namew = None

        # Widget checkbox to use solver or not
        self.usesolver = None

        # A variable which take the linear solver class
        self.linear = None

        # A variable which take the nonlinear solver class
        self.nonlinear = None

        # Widget button to add a subgroup
        self.addMod = None

        # List of the models
        self.models = []

        # List of the components
        self.components = []

        # The text to write on the yaml file
        self.txt = ""

        # Vbox to display several widgets and hide them
        self.vbox = v.Html(
            tag="div",
            class_="d-flex justify-center mb-6",
            children=[
                v.Html(tag="div", children=[]),
                v.Html(tag="div", children=[]),
            ],
        )

        # Call the initialize function
        self.initialize()
コード例 #18
0
    def __init__(self, model):

        # create the widgets
        baseline_title = v.Html(tag="h4",
                                children=[cm.input_lbl.baseline],
                                class_="mb-0 mt-5")
        baseline_start_picker = sw.DatePicker(label=cm.input_lbl.start)
        baseline_end_picker = sw.DatePicker(label=cm.input_lbl.end)
        baseline_picker_line = v.Layout(
            xs12=True,
            row=True,
            children=[baseline_start_picker, baseline_end_picker])

        analysis_title = v.Html(tag="h4",
                                children=[cm.input_lbl.analysis],
                                class_="mb-0 mt-5")
        analysis_start_picker = sw.DatePicker(label=cm.input_lbl.start)
        analysis_end_picker = sw.DatePicker(label=cm.input_lbl.end)
        analysis_picker_line = v.Layout(
            xs12=True,
            row=True,
            children=[analysis_start_picker, analysis_end_picker])

        # bind the widgets
        model.bind(baseline_start_picker, "reference_start").bind(
            baseline_end_picker, "reference_end").bind(analysis_start_picker,
                                                       "analysis_start").bind(
                                                           analysis_end_picker,
                                                           "analysis_end")

        super().__init__(
            "nested_widget",
            cm.tile.time,
            inputs=[
                baseline_title,
                baseline_picker_line,
                analysis_title,
                analysis_picker_line,
            ],
        )
コード例 #19
0
    def _get_matrix(self, code_fields, classes_file=""):
        """Init table reading local classes file and code/categories fields

        Args:
            code_fields (list) : List of codes/categories of raster/feature collection
            classes_file (str) : Classes file containing code/category and description
        """

        self.matrix = {}

        # Set empty items if there is not a file selected
        self.items = []

        if classes_file:
            self.items = self.read_classes_from_file(classes_file)

        headers = ["From: user code", "To: Custom Code"]

        # Instantiate an empty dictionary with code as
        # keys and empty values
        for code in code_fields:
            self.matrix[code] = ""

        header = [
            v.Html(tag="tr",
                   children=([v.Html(tag="th", children=[h])
                              for h in headers]))
        ]

        rows = [
            v.Html(
                tag="tr",
                children=[
                    v.Html(tag="td", children=[str(code)]),
                    self.get_classes(code),
                ],
            ) for code in code_fields
        ]

        self.children = [v.Html(tag="tbody", children=header + rows)]
コード例 #20
0
ファイル: alert.py プロジェクト: 12rambau/sepal_ui
    def append_msg(self, msg, section=False, type_='info'):
        """ 
        Append a message in a new parragraph, with or without divider

        Args: 
            msg (str): the message to display
            section (bool, optional): add a Divider before the added message
            
        Return:
            self
        """
        
        self.show()
        self.type=type_
        
        if len(self.children):
            current_children = self.children[:]
            if section:
                # As the list is mutable, and the trait is only triggered when
                # the children is changed, so have to create a copy.
                divider = Divider(class_='my-4', style='opacity: 0.22')

                # link Alert type with divider type
                directional_link((self, 'type'), (divider, 'type_'))
                current_children.extend([
                    divider,
                    v.Html(tag='p', children=[msg])
                ])
                self.children = current_children

            else:
                current_children.append(
                    v.Html(tag='p', children=[msg])
                )
                self.children = current_children
        else:
            self.add_msg(msg)
            
        return self
コード例 #21
0
    def __init__(self, byte_map=None):

        header = v.Html(tag='thead',
                        children=[
                            v.Html(tag='tr',
                                   children=[
                                       v.Html(tag='th',
                                              children=['old value']),
                                       v.Html(tag='th', children=['new value'])
                                   ])
                        ])

        self.tbody = v.Html(tag='tbody', children=[])

        # add a  hidden textfield to save the json
        self.save = v.TextField(v_model=json.dumps({i: i for i in range(256)}))

        # load the body
        self.reload_body(byte_map)

        # create the actual table
        super().__init__(children=[header, self.tbody], class_="mb-5")
コード例 #22
0
    def reload_body(self, raster):
        """dynamically change the body of the widget according to the raster file"""

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

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

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

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

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

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

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

        self.tbody.children += tmp_children

        return self
コード例 #23
0
def update_progress(progress, output, msg='Progress', bar_length=30):
    # not working yet in ipyvuetify
    plain_char = '█'
    empty_char = ' '
    progress = float(progress)
    block = int(round(bar_length * progress))

    text = f'|{plain_char * block + empty_char * (bar_length - block)}|'

    output.add_live_msg(
        v.Html(tag='span',
               children=[
                   v.Html(tag='span', children=[f'{msg}: '],
                          class_='d-inline'),
                   v.Html(tag='pre',
                          class_='info--text d-inline',
                          children=[text]),
                   v.Html(tag='span',
                          children=[f' {progress *100:.1f}%'],
                          class_='d-inline')
               ]))

    return
コード例 #24
0
    def __init__(self):

        # Text to return in the yaml file
        self.driver = None

        # Ipyvuetify widgets
        self.select = None

        self.generator = None

        self.selectDriver = None

        # Vbox to display several widgets and hide them
        self.vboxdriver = v.Html(
            tag="div",
            class_="d-flex justify-center mb-6",
            children=[
                v.Html(
                    tag="div", children=[]
                ),
                v.Html(
                    tag="div", children=[]
                ),
            ],
        )

        self.vboxdoedriver = v.Html(
            tag="div",
            class_="d-flex justify-center mb-6",
            children=[
                v.Html(
                    tag="div", children=[]
                ),
                v.Html(
                    tag="div", children=[]
                ),
            ],
        )

        self.vboxgenerator = v.Html(
            tag="div",
            children=[
                v.Html(
                    tag="div", children=[]
                ),
            ],
        )
コード例 #25
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
コード例 #26
0
    def __init__(self):

        # Text to return in the yaml file
        self.solver = None

        # Ipyvuetify widgets
        self.select = None

        self.panel = None

        self.expansionPanel = None

        # Vbox to display several widgets and hide them
        self.vboxnonlinearsolver = v.Html(
            tag="div",
            class_="d-flex justify-center mb-6",
            children=[
                v.Html(tag="div", children=[]),
                v.Html(tag="div", children=[]),
            ],
        )

        self.vboxaitken = v.Html(
            tag="div",
            class_="d-flex justify-center mb-6",
            children=[
                v.Html(tag="div", children=[]),
                v.Html(tag="div", children=[]),
            ],
        )

        self.vboxsubsolves = v.Html(
            tag="div",
            class_="d-flex justify-center mb-6",
            children=[
                v.Html(tag="div", children=[]),
                v.Html(tag="div", children=[]),
            ],
        )
コード例 #27
0
ファイル: alert.py プロジェクト: 12rambau/sepal_ui
 def add_msg(self, msg, type_='info'):
     """
     Add a message in the alert by replacing all the existing one. 
     The color can also be changed dynamically
     
     Args:
         msg (str): the message to display
         type\_ (str, optional): the color to use in the widget
         
     Return:
         self
     """
     self.show()
     self.type = type_ if (type_ in TYPES) else TYPES[0]
     self.children = [v.Html(tag='p', children=[msg])]
     
     return self
コード例 #28
0
    def __init__(self):
        log.info("__init__")
        self.cl = int_field(settings.CACHE_LINES_VAL,
                            settings.CACHE_LINES_DESC)
        self.cb = int_field(settings.CACHE_BLOCK_VAL,
                            settings.CACHE_BLOCK_DESC)
        self.ml = int_field(settings.OUTPUT_LINES_VAL,
                            settings.OUTPUT_LINES_DESC)

        self.cwd = Combobox(placeholder=settings.CWD_PATH_DEF,
                            options=load_cwd_file(),
                            description=settings.CWD_PATH_DESC,
                            style=settings.WIDGET_DESC_PROP,
                            layout=settings.WIDGET_LAYOUT)

        self.ex = text_field(settings.EXEC_PATH_DEF, settings.EXEC_PATH_DESC)
        self.to = text_field(settings.TRACE_NAME_DEF, settings.TRACE_NAME_DESC)
        self.st = text_field(settings.START_FUN_DEF, settings.START_FUN_DESC)

        self.vh = v.Html(
            tag='style',
            children=[".v-input__slot .v-label{color: black!important}"])

        self.gt_in = VBox([
            self.cl, self.cb, self.ml, self.cwd, self.ex, self.to, self.st,
            self.vh
        ],
                          layout=Layout(width='100%'))

        self.gb = button(settings.GENERATE_DESC, color=settings.GENERATE_COLOR)
        self.lb = button(settings.LOAD_DESC, color=settings.LOAD_COLOR)
        self.db = button(settings.DELETE_DESC, color=settings.DELETE_COLOR)
        self.bs = HBox([self.gb, self.lb, self.db])

        self.sw = SelectMultiple(options=[],
                                 value=[],
                                 description=settings.SELECT_MULTIPLE_DESC,
                                 layout=settings.WIDGET_LAYOUT,
                                 rows=10)

        self.tw = HBox([self.gt_in, self.sw],
                       layout=Layout(justify_content="space-around"))
        self.widgets = VBox([self.tw, self.bs],
                            layout=Layout(justify_content="space-around"))
コード例 #29
0
    def __init__(self, model):
        self.model = model

        self.panels = v.ExpansionPanels(accordion=True,
                                        multiple=True,
                                        v_model=[])
        up = 'keyboard_arrow_up'
        down = 'keyboard_arrow_down'
        legend_icon = v.Icon(children=[down])
        self.legend_button = v.Btn(icon=True, children=[legend_icon])
        # Style to remove gray background in panels, and remove padding in panel contents
        panel_style = v.Html(
            tag='style',
            children=[
                ".v-application--wrap{background-color: white!important} .v-expansion-panel-content__wrap{padding:0!important}"
            ])
        self.widgets = VBox([self.panels, panel_style],
                            layout=Layout(padding='0px',
                                          border='1px solid black',
                                          width='400px'))
        self.accesses = Accesses(model, self.update_selection)
        self.stats = PlotStats(model)
        self.tags = Tags(model, self.update_selection)
        self.add_panel(LEGEND_MEM_ACCESS_TITLE, self.accesses.widgets)
        self.add_panel(LEGEND_TAGS_TITLE, self.tags.widgets)
        self.add_panel(LEGEND_STATS_TITLE, self.stats.widgets)

        def update_legend_icon(_panels, _, selected):
            if len(selected) == len(self.panels.children):
                legend_icon.children = [up]
            elif selected == []:
                legend_icon.children = [down]

        self.panels.on_event('change', update_legend_icon)

        def update_panels(*args):
            if legend_icon.children[0] == up:
                legend_icon.children = [down]
                self.panels.v_model = []
            else:
                legend_icon.children = [up]
                self.panels.v_model = list(range(len(self.panels.children)))

        self.legend_button.on_event('click', update_panels)
コード例 #30
0
def message_widget(msg, kind='warning'):
    """Makes a warning snackbar.

    Only one snackbar is allowed at a time, so only
    one warning is displayed at a time.  Older warnings
    will be closed early if a new one is requested.

    Properties:
        msg (str): The warning string.
        kind (str): Kind of message ('info', 'success', 'warning', or 'error').
    """
    if kind == 'info':
        color = INFO_COLOR
        icon = 'info'
    elif kind == 'success':
        color = SUCCESS_COLOR
        icon = 'info'
    elif kind == 'warning':
        color = WARNING_COLOR
        icon = 'warning'
    elif kind == 'error':
        color = ERROR_COLOR
        icon = 'error'
    else:
        raise ValueError('Invalid input kind for message.')

    msg_html = vue.Html(tag='div',
                        children=[msg],
                        style_='font-weight: light; font-size: 14px;'
                        'margin: 0px 5px 0px 0px')

    children = [msg_html]

    msg_widget = vue.Alert(children=children,
                           outlined=False,
                           dense=True,
                           elevation=0,
                           text=True,
                           type=kind,
                           border="left",
                           style_='margin: 0px')

    display(msg_widget)