Beispiel #1
0
    def __init__(self, items, code=None, wiki=None, issue=None, **kwargs):

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

        super().__init__(v_model=True,
                         app=True,
                         color=sepal_darker,
                         children=[
                             v.List(dense=True, children=items),
                             v.Divider(),
                             v.List(dense=True, children=code_link)
                         ],
                         **kwargs)
Beispiel #2
0
    def __init__(self, items=[], code=None, wiki=None, issue=None, **kwargs):

        self.items = items

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

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

        # bind the javascripts behavior
        for i in self.items:
            i.observe(self._on_item_click, 'input_value')
Beispiel #3
0
    def __init__(self,
                 extentions=['.txt'],
                 folder=os.path.expanduser('~'),
                 label='select file',
                 **kwargs):

        self.extentions = extentions
        self.folder = folder

        self.selected_file = v.TextField(label='file', v_model=self.file)

        self.file_list = v.List(
            dense=True,
            color='grey lighten-4',
            flat=True,
            children=[v.ListItemGroup(children=self.get_items(), v_model='')])

        self.file_menu = v.Menu(min_width=300,
                                children=[self.file_list],
                                close_on_content_click=False,
                                max_height='300px',
                                v_slots=[{
                                    'name':
                                    'activator',
                                    'variable':
                                    'x',
                                    'children':
                                    v.Btn(v_model=False,
                                          v_on='x.on',
                                          children=[label])
                                }])

        super().__init__(row=True,
                         class_='pa-5',
                         align_center=True,
                         children=[
                             v.Flex(xs12=True, children=[self.selected_file]),
                             v.Flex(xs12=True, children=[self.file_menu])
                         ],
                         **kwargs)

        link((self.selected_file, 'v_model'), (self, 'file'))

        def on_file_select(change):

            new_value = change['new']
            if new_value:
                if os.path.isdir(new_value):
                    self.folder = new_value
                    self.change_folder()

                elif os.path.isfile(new_value):
                    self.file = new_value

        self.file_list.children[0].observe(on_file_select, 'v_model')
Beispiel #4
0
def NavDrawer(items, code = False, wiki = False, issue = None):
    """ 
    create a navdrawer using the different items of the user and the sepal color framework. The drawer always include links to the github page of the project for wiki, bugs and repository.
    
    Args:
        items ([v.ListItem]) : the list of the list item the user wants to add to the nav drawer
        code (str, optionnal) : the absolute link to the github code. not display if None
        wiki (str, optionnal) : the absolute link to the github wiki. not display if None
        issue (str, optionnal) : the absolute link to the github issues. not display if None
    
    Returns:
        navDrawer (v.NavigationDrawer) : the nav drawer of the web page
    """
    
    code_link = []
    if code:
        item_code = DrawerItem('Source code', icon='mdi-file-code', href=code)
        code_link.append(item_code)
    if wiki:
        item_wiki = DrawerItem('Wiki', icon='mdi-book-open-page-variant', href=wiki)
        code_link.append(item_wiki)
    if issue:
        item_bug = DrawerItem('Bug report', icon='mdi-bug', href=issue)
        code_link.append(item_bug)
        
    
        
    navDrawer = v.NavigationDrawer(
        v_model=True, 
        app= True,
        color=sepal_darker,
        children=[
            v.List(dense=True, children=items),
            v.Divider(),
            v.List(dense=True, children=code_link),
        ]
    )
    
    return navDrawer
Beispiel #5
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')
        ])
    ]
Beispiel #6
0
    def __init__(self, session=None, output_widget=None):

        self.output = output_widget
        self.session = session

        self.modes = [
            ("replace", icon_replace, ReplaceMode),
            ("add", icon_or, OrMode),
            ("and", icon_and, AndMode),
            ("xor", icon_xor, XorMode),
            ("remove", icon_andnot, AndNotMode),
        ]

        items = []
        for mode in self.modes:
            item = v.ListItem(children=[v.ListItemAction(children=[mode[1]]),
                                        v.ListItemTitle(children=[mode[0]])])
            items.append(item)

        for item in items:
            item.on_event('click', self._sync_state_from_ui)

        mylist = v.List(children=items)

        self.main = v.Btn(icon=True,
                          children=[self.modes[0][1]], v_on="menu.on")

        super().__init__(
            v_slots=[{
                'name': 'activator',
                'variable': 'menu',
                'children': self.main
            }],
            children=[mylist])

        self.session.hub.subscribe(self, msg.EditSubsetMessage,
                                   handler=self._on_edit_subset_msg)

        self._sync_ui_from_state(self.session.edit_subset_mode.mode)
Beispiel #7
0
 def __init__(self):
     
     # create the extra widget
     self.state = sw.StateBar(done=True)
     self.color = v.ListItemGroup(v_model = None, children=[v.ListItem(children= [c], value=c) for c in cp.planet_colors[:4]])
     self.palette = v.Menu(
         value=False,
         v_slots=[{
             'name': 'activator',
             'variable': 'menu',
             'children': v.Btn(v_model = False, v_on='menu.on', color='primary', icon = True, children=[v.Icon(children=['mdi-palette'])])
         }],
         children = [v.List(dense=True, outlined=True, rounded=True, children=[self.color])]
     )
     
     # create the map 
     super().__init__(gee=False)
     
     # add the widget to the map (as to left and right items)
     self.add_control(WidgetControl(widget=self.state, position='topleft'))
     self.add_control(WidgetControl(widget=self.palette, position='topleft'))
     
     # create jslinks
     jslink((self, 'combo'), (self.color, 'v_model'))
    def __init__(self, viewer):

        self.output = viewer.output_widget
        self.session = viewer.session

        self.modes = viewer.toolbar_selection_mode.selection_modes

        items = []
        for mode in self.modes:
            item = v.ListItem(children=[
                v.ListItemAction(children=[mode[1]]),
                v.ListItemTitle(children=[mode[0]])
            ])
            items.append(item)

        for item in items:
            item.on_event('click', self._sync_state_from_ui)

        mylist = v.List(children=items)

        self.main = v.Btn(icon=True,
                          children=[self.modes[0][1]],
                          v_on="menu.on")

        super().__init__(v_slots=[{
            'name': 'activator',
            'variable': 'menu',
            'children': self.main
        }],
                         children=[mylist])

        self.session.hub.subscribe(self,
                                   msg.EditSubsetMessage,
                                   handler=self._on_edit_subset_msg)

        self._sync_ui_from_state(self.session.edit_subset_mode.mode)
Beispiel #9
0
menu = v.Menu(offset_y=True,
              v_slots=[{
                  'name':
                  'activator',
                  'variable':
                  'menuData',
                  'children':
                  v.Btn(v_on='menuData.on',
                        color='primary',
                        children=[
                            'menu',
                            v.Icon(right=True, children=['mdi-menu-down'])
                        ]),
              }],
              children=[v.List(children=items)])

dialog = v.Dialog(
    width='500',
    v_slots=[{
        'name':
        'activator',
        'variable':
        'x',
        'children':
        v.Btn(v_on='x.on',
              color='success',
              dark=True,
              children=['Open dialog']),
    }],
    children=[
Beispiel #10
0
    def init_widgets(self, tag_type):
        self.all_check = v.Checkbox(v_on='tooltip.on',
                                    prepend_icon='fa-globe',
                                    label="All",
                                    v_model=True,
                                    class_='ma-0 mt-1 pa-0')
        self.all_check_tp = v.Tooltip(bottom=True,
                                      v_slots=[{
                                          'name': 'activator',
                                          'variable': 'tooltip',
                                          'children': self.all_check
                                      }],
                                      children=["Select all"])
        self.all_check.on_event('change', self.check_all)
        all_row = [v.Row(children=[self.all_check_tp], class_='ml-7')]

        tag_rows = []
        treenodelabel = v.Html(
            tag='style',
            children=
            [(".vuetify-styles .v-treeview-node__label {"
              "margin-left: 0px;"
              "overflow: visible;"
              "}"
              ".vuetify-styles .v-input--selection-controls:not(.v-input--hide-details) .v-input__slot {"
              "margin-bottom: 0px;"
              "}"
              ".vuetify-styles .v-treeview-node__root .v-icon.v-icon.v-icon--link {"
              "margin-bottom: 10px;"
              "}"
              ".vuetify-styles .v-treeview-node--leaf {"
              "margin-left: 0px;"
              "}"
              ".vuetify-styles .v-treeview--dense .v-treeview-node__root {"
              "min-height: 21px;"
              "}")])

        for tag in self.model.curr_trace.tags:
            if tag.tag_type == tag_type:
                chk = Checkbox(tag)
                self.checkboxes.append(chk)
                chk.widget.on_event('change', self.update_all_checkbox)
                stats = self.get_stats(tag)
                btn, tooltip = self.create_zoom_button(tag, stats=stats)
                statss = self.tag_tooltip(tag, stats).splitlines()

                tag_row = v.Row(children=[btn, chk.widget], class_='ml-0')
                items = [{
                    'id':
                    1,
                    'name':
                    '',
                    'children': [{
                        'id': i + 2,
                        'name': stat
                    } for i, stat in enumerate(statss)],
                }]
                treeview = v.Treeview(items=items, dense=True)
                tag_rows.append(
                    v.Container(row=False,
                                class_="d-flex justify-start ma-0 pa-0",
                                children=[
                                    v.Col(cols=1,
                                          children=[treeview],
                                          class_="ma-0 pa-0"),
                                    v.Col(cols=12,
                                          children=[tag_row],
                                          class_="pt-0 pb-0")
                                ]))
        tag_rows.append(v.Container(row=False, children=[treenodelabel]))
        return VBox([
            v.List(children=(all_row + tag_rows),
                   dense=True,
                   nav=True,
                   max_height="300px",
                   max_width="300px")
        ])
Beispiel #11
0
    def __init__(self,
                 extentions=[],
                 folder=os.path.expanduser('~'),
                 label='search file',
                 **kwargs):

        self.extentions = extentions
        self.folder = folder

        self.selected_file = v.TextField(label='Selected file',
                                         class_='ml-5 mt-5',
                                         v_model=self.file)

        self.loading = v.ProgressLinear(
            indeterminate=False, color=COMPONENTS['PROGRESS_BAR']['color'])

        self.file_list = v.List(dense=True,
                                color='grey lighten-4',
                                flat=True,
                                children=[
                                    self.loading,
                                    v.ListItemGroup(children=self.get_items(),
                                                    v_model='')
                                ])

        self.file_menu = v.Menu(min_width=300,
                                children=[self.file_list],
                                close_on_content_click=False,
                                max_height='300px',
                                v_slots=[{
                                    'name':
                                    'activator',
                                    'variable':
                                    'x',
                                    'children':
                                    Btn(icon='mdi-file-search',
                                        v_model=False,
                                        v_on='x.on',
                                        text=label)
                                }])

        super().__init__(row=True,
                         class_='d-flex align-center mb-2',
                         align_center=True,
                         children=[
                             self.file_menu,
                             self.selected_file,
                         ],
                         **kwargs)

        link((self.selected_file, 'v_model'), (self, 'file'))

        def on_file_select(change):
            new_value = change['new']
            if new_value:
                if os.path.isdir(new_value):
                    self.folder = new_value
                    self.change_folder()

                elif os.path.isfile(new_value):
                    self.file = new_value

        self.file_list.children[1].observe(on_file_select, 'v_model')
Beispiel #12
0
    def __init__(self, filename, vizapp):

        self._vizapp = vizapp

        self._vizapp.glue_app.load_data(filename)

        #
        #  Create File Menu
        #
        self.tile_load = v.ListTile(
            children=[v.ListTileTitle(children=["Load"])])
        self.tile_save = v.ListTile(
            children=[v.ListTileTitle(children=["Save"])])
        self.tile_load.on_event('click', self._on_change_menu_bar_file)
        self.tile_save.on_event('click', self._on_change_menu_bar_file)
        self.f_items = [self.tile_load, self.tile_save]

        self._menu_bar_file = v.Layout(children=[
            v.Menu(offset_y=True,
                   children=[
                       v.Btn(slot='activator',
                             color='primary',
                             children=[
                                 'File',
                                 v.Icon(right=True,
                                        children=['arrow_drop_down'])
                             ]),
                       v.List(children=self.f_items)
                   ])
        ])

        #
        #  Create Add Viewer Menu
        #
        self.tile_3d_viewer = v.ListTile(
            children=[v.ListTileTitle(children=["3D Viewer"])])
        self.tile_3d_viewer.on_event('click', self._on_change_menu_bar_viewer)
        self.v_items = [self.tile_3d_viewer]

        self._menu_bar_viewer = v.Layout(children=[
            v.Menu(offset_y=True,
                   children=[
                       v.Btn(slot='activator',
                             color='primary',
                             children=[
                                 'Add Viewer',
                                 v.Icon(right=True,
                                        children=['arrow_drop_down'])
                             ]),
                       v.List(children=self.v_items)
                   ])
        ])

        # Add to menu bar
        self._menu_bar = v.Layout(row=True,
                                  wrap=True,
                                  children=[
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._menu_bar_file]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._menu_bar_viewer]),
                                  ])

        self._menu_bar.box_style = 'success'

        self._v3d = ViewerND(self._vizapp)

        # Going to set the upper percentile rather than use the max value.
        self._v3d._v3d.state.layers[0].percentile = 99.5

        self._main_box = v.Layout(row=True,
                                  wrap=True,
                                  children=[
                                      v.Flex(xs12=True,
                                             class_='px-2',
                                             children=[self._menu_bar]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._v3d.show()]),
                                  ])
Beispiel #13
0
    def __init__(self, filename, vizapp, process_data=None):

        self._vizapp = vizapp

        self._vizapp.glue_app.load_data(filename)
        if process_data is not None:
            process_data(self)

        #
        #  Create File Menu
        #
        self.tile_load = v.ListTile(
            children=[v.ListTileTitle(children=["Load"])])
        self.tile_save = v.ListTile(
            children=[v.ListTileTitle(children=["Save"])])
        self.tile_load.on_event('click', self._on_change_menu_bar_file)
        self.tile_save.on_event('click', self._on_change_menu_bar_file)
        self.f_items = [self.tile_load, self.tile_save]

        self._menu_bar_file = v.Layout(children=[
            v.Menu(offset_y=True,
                   children=[
                       v.Btn(slot='activator',
                             color='primary',
                             children=[
                                 'File',
                                 v.Icon(right=True,
                                        children=['arrow_drop_down'])
                             ]),
                       v.List(children=self.f_items)
                   ])
        ])

        #
        #  Create Add Viewer Menu
        #
        self.tile_3d_viewer = v.ListTile(
            children=[v.ListTileTitle(children=["3D Viewer"])])
        self.tile_1d_viewer = v.ListTile(
            children=[v.ListTileTitle(children=["1D Viewer"])])
        self.tile_3d_viewer.on_event('click', self._on_change_menu_bar_viewer)
        self.tile_1d_viewer.on_event('click', self._on_change_menu_bar_viewer)
        self.v_items = [self.tile_3d_viewer, self.tile_1d_viewer]

        self._menu_bar_viewer = v.Layout(children=[
            v.Menu(offset_y=True,
                   children=[
                       v.Btn(slot='activator',
                             color='primary',
                             children=[
                                 'Add Viewer',
                                 v.Icon(right=True,
                                        children=['arrow_drop_down'])
                             ]),
                       v.List(children=self.v_items)
                   ])
        ])

        # Add to menu bar
        self._menu_bar = v.Layout(row=True,
                                  wrap=True,
                                  children=[
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._menu_bar_file]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._menu_bar_viewer]),
                                  ])

        self._menu_bar.box_style = 'success'

        self._v1d = Viewer1D(self._vizapp)
        self._v3d = ViewerND(self._vizapp)

        self._main_box = v.Layout(row=True,
                                  wrap=True,
                                  children=[
                                      v.Flex(xs12=True,
                                             class_='px-2',
                                             children=[self._menu_bar]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._v3d.show()]),
                                      v.Flex(xs6=True,
                                             class_='px-2',
                                             children=[self._v1d.show()]),
                                  ])
Beispiel #14
0
    def __init__(self,
                 extentions=[],
                 folder=os.path.expanduser('~'),
                 label='search file',
                 v_model=None,
                 **kwargs):

        self.extentions = extentions
        self.folder = folder

        self.selected_file = v.TextField(readonly=True,
                                         label='Selected file',
                                         class_='ml-5 mt-5',
                                         v_model=self.file)

        self.loading = v.ProgressLinear(
            indeterminate=False,
            background_color='grey darken-3',
            color=COMPONENTS['PROGRESS_BAR']['color'])

        self.file_list = v.List(
            dense=True,
            color='grey darken-3',
            flat=True,
            max_height='300px',
            style_='overflow: auto; border-radius: 0 0 0 0;',
            children=[v.ListItemGroup(children=self._get_items(), v_model='')])

        self.file_menu = v.Menu(min_width=300,
                                children=[self.loading, self.file_list],
                                close_on_content_click=False,
                                v_slots=[{
                                    'name':
                                    'activator',
                                    'variable':
                                    'x',
                                    'children':
                                    Btn(icon='mdi-file-search',
                                        v_model=False,
                                        v_on='x.on',
                                        text=label)
                                }])

        self.reload = v.Btn(icon=True,
                            color='primary',
                            children=[v.Icon(children=['mdi-cached'])])

        super().__init__(row=True,
                         class_='d-flex align-center mb-2',
                         align_center=True,
                         children=[
                             self.reload,
                             self.file_menu,
                             self.selected_file,
                         ],
                         **kwargs)

        link((self.selected_file, 'v_model'), (self, 'file'))
        link((self.selected_file, 'v_model'), (self, 'v_model'))

        self.file_list.children[0].observe(self._on_file_select, 'v_model')
        self.reload.on_event('click', self._on_reload)
Beispiel #15
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])
            ])
Beispiel #16
0
def main():

    tc = TestCaseWidget(cases, default_case)
    lb = LBSchemeWidget(tc, known_cases)

    stability = StabilityWidget(tc, lb)
    simulation = SimulationWidget(tc, lb)
    parametric = ParametricStudyWidget(tc, lb, simulation.discret)
    posttreatment = PostTreatmentWidget()

    class DebugWidget:
        def __init__(self):
            self.menu = []
            self.main = [out]

    tab_widgets = [
        tc, lb, stability, simulation, parametric, posttreatment,
        DebugWidget()
    ]
    tab_titles = [
        'Test case', 'Scheme', 'Linear stability', 'LBM Simulation',
        'Parametric study', 'Post treatment', 'Debug'
    ]

    tab = v.Tabs(
        v_model=0,
        center_active=True,
        fixed_tabs=True,
        slider_size=4,
        align_with_title=True,
        show_arrows=True,
        children=[v.Tab(children=[k]) for k in tab_titles],
    )

    menu = v.List(
        children=[],
        nav=True,
        v_model='drawer',
    )
    content = v.Content(children=[])

    def tab_change(change):
        tab_id = tab.v_model
        widget = tab_widgets[tab_id]
        menu.children = [
            v.ListItem(children=[v.ListItemContent(children=[m])])
            for m in widget.menu
        ]
        content.children = widget.main

        if tab_id == 5:
            posttreatment.update(None)

    tab_change(None)
    tab.observe(tab_change, 'v_model')

    navicon = v.AppBarNavIcon()

    drawer = v.NavigationDrawer(children=[
        v.Row(children=[
            v.Img(
                src=
                'https://pylbm.readthedocs.io/en/latest/_static/img/pylbm_with_text.svg',
                max_width=250,
                class_='ma-5')
        ],
              align='center',
              justify='center'), menu
    ],
                                v_model=True,
                                width=350,
                                clipped=True,
                                app=True)

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

    navicon.on_event("click.stop", show_drawer)

    return v.App(children=[
        v.AppBar(
            children=[
                navicon,
                tab,
            ],
            clipped_left=True,
            app=True,
            dark=True,
        ),
        drawer,
        content,
    ])
Beispiel #17
0
    def __init__(self, flip_func):

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

        self.output = Output()

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

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

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

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

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

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

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

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

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

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

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

        # Sidebar Layout
        self.drawer = v.Card(
            children=[
                v.NavigationDrawer(
                    width='325px',
                    dark=True,
                    color='#FF000000',
                    #expand_on_hover=True,
                    mini_variant_width='75px',
                    fixed=True,  # *
                    floating=True,
                    #permanent=True,
                    #mini_variant=True,
                    #app=True,
                    #disable_route_watcher=True,
                    #disable_resize_watcher=True,
                    #v_model='drawer',
                    #hide_overlay=True,
                    #clipped=True,
                    #absolute=True,
                    #touchless=True,
                    children=[
                        v.List(
                            children=[
                                v.ListItem(children=[
                                    self.upload_btn, self.img_selector
                                ],
                                           class_='d-flex align-stretch mb-6',
                                           style_='height: 40px;'),
                                v.ListItem(children=[
                                    self.flip_hist_btn, self.colorspace_sel
                                ],
                                           class_='d-flex align-stretch mb-6',
                                           style_='height: 40px;'),
                                #v.ListItem(
                                #    children=[
                                #        self.save_op_btn,
                                #        self.save_img_btn,
                                #        self.save_chart_btn,
                                #        self.show_console_btn,
                                #        ],
                                #    class_='d-flex align-stretch mb-6',
                                #    style_='\
                                #            height: 40px; \
                                #            '
                                #    ),
                                v.ListItem(children=[
                                    self.github_btn,
                                    self.op_selector,
                                ],
                                           class_='d-flex align-stretch mb-6',
                                           style_='\
                                            height: 100%; \
                                            '),
                            ],
                            style_='background-color: #000000BF'),
                        v.Divider(),
                        v.List(children=[
                            v.ListItem(children=[
                                self.op_panel,
                            ],
                                       class_='d-flex align-stretch mb-6',
                                       style_='\
                                                width: 100%; \
                                                height: 100%; \
                                                '),
                        ])
                    ])
            ],
            class_='d-flex flex-column mb-12',
        )
Beispiel #18
0
 def _get_layout(self):
     return v.Container(
         pa_4=True,
         _metadata={"mount_id": "content-nav"},
         column=True,
         children=[v.List(dense=True, children=self.__elements)])
Beispiel #19
0
def main():

    mc = ModelWidget(cases)
    tc = TestCaseWidget(mc)
    lb = LBSchemeWidget(tc)

    stability =  StabilityWidget(tc, lb)
    simulation = SimulationWidget(tc, lb)
    parametric = ParametricStudyWidget(tc, lb, simulation.discret, simulation.codegen)
    posttreatment = PostTreatmentWidget()

    class DebugWidget:
        def __init__(self):
            self.menu = []
            self.main = [out]

    tab_widgets = [
        mc,
        tc, lb,
        stability, simulation,
        parametric, posttreatment,
        DebugWidget()
    ]
    tab_titles = [
        'Model',
        'Test case', 'Scheme',
        'Linear stability', 'LBM Simulation',
        'Parametric study', 'Post treatment',
        'Debug'
    ]

    tab = v.Tabs(
        v_model=0,
        center_active=True,
        fixed_tabs=True,
        slider_size=4,
        align_with_title=True,
        show_arrows=True,
        children=[v.Tab(children=[k]) for k in tab_titles],
    )

    menu = v.List(
        children=[],
        nav=True,
        v_model='drawer',
    )
    content = v.Content(children=[])

    def tab_change(change):
        tab_id = tab.v_model

        items = []
        if tab_id < 6:
            items.extend(get_information(tab_id, mc, tc, lb))

        widget = tab_widgets[tab_id]
        items.extend([
            v.ListItem(
                children=[
                    v.ListItemContent(children=[m])
                ]
            ) for m in widget.menu
        ])

        menu.children = items
        content.children = widget.main

        if tab_id == 4:
            simulation.update_simu_cfg_list()

        if tab_id == 5:
            parametric.update_param_cfg_list()

        if tab_id == 6:
            posttreatment.update(None)

    tab_change(None)
    tab.observe(tab_change, 'v_model')
    mc.select_category.observe(tab_change, 'v_model')
    mc.select_model.observe(tab_change, 'v_model')
    tc.select_case.observe(tab_change, 'v_model')
    lb.select_case.observe(tab_change, 'v_model')

    navicon = v.AppBarNavIcon()

    drawer = v.NavigationDrawer(
        children=[
            v.Row(
                children=[
                    v.Img(
                        src='img/pylbm_with_text.svg',
                        max_width=250, class_='ma-5'
                    )
                ],
                align='center',
                justify='center'
            ),
            menu
        ],
        v_model=True,
        width=350,
        clipped=True,
        app=True
    )

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

    navicon.on_event("click.stop", show_drawer)

    return v.App(
        children=[
            v.AppBar(
                children=[
                    navicon,
                    tab,
                ],
                clipped_left=True,
                app=True,
                dark=True,
            ),
            drawer,
            content,
        ]
    )