def App (tiles=[''], appBar=None, footer=None, navDrawer=None): """ Create an app display with the tiles created by the user. Display false footer and appBar if not filled. navdrawer is fully optionnal Args: tiles ([v.Layout]) : the list of tiles the user want to display in step order. appBar (v.appBar, optionnal) : the custom appBar of the module footer (v.Footer, optionnal) : the custom footer of the module navDrawer (v.NavigationDrawer, optional) : the navigation drawer to allow the display of specific tiles Returns: app (v.App) : the complete app to display toolBarButton (v.Btn) : the created toolbarButton, None if the appBar was already existing """ app = v.App(v_model=None) app_children = [] #add the navDrawer if existing if navDrawer: app_children.append(navDrawer) #create a false appBar if necessary toolBarButton = None if not appBar: appBar, toolBarButton = AppBar() app_children.append(appBar) #add the content of the app content = v.Content(children=[v.Container(fluid=True,children = tiles)]) app_children.append(content) app.children = app_children return (app, toolBarButton)
def __init__(self, tiles=[''], appBar=None, footer=None, navDrawer=None, **kwargs): self.tiles = None if tiles == [''] else tiles app_children = [] #add the navDrawer if existing if navDrawer: app_children.append(navDrawer) #create a false appBar if necessary if not appBar: appBar = AppBar() app_children.append(appBar) #add the content of the app content = v.Content(children=[v.Container(fluid=True, children=tiles)]) app_children.append(content) #create a false footer if necessary if not footer: footer = Footer() app_children.append(footer) super().__init__(v_model=None, children=app_children, **kwargs)
def __init__(self, tiles=[''], appBar=None, footer=None, navDrawer=None, **kwargs): self.tiles = None if tiles == [''] else tiles app_children = [] # create a false appBar if necessary if not appBar: appBar = AppBar() self.appBar = appBar app_children.append(self.appBar) # add the navDrawer if existing self.navDrawer = None if navDrawer: # bind app tile list to the navdrawer for di in navDrawer.items: di.display_tile(tiles) # link it with the appbar navDrawer.display_drawer(self.appBar.toggle_button) # add the drawers to the children self.navDrawer = navDrawer app_children.append(self.navDrawer) # add the content of the app self.content = v.Content( children=[v.Container(fluid=True, children=tiles)]) app_children.append(self.content) # add the footer if existing if footer: self.footer = footer app_children.append(self.footer) # create a negative overlay to force the background color bg = v.Overlay(color=color.bg, opacity=1, style_='transition:unset', z_index=-1) super().__init__(v_model=None, children=[bg, *app_children], **kwargs)
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, ] )
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, ])