def draw(): return v.Layout(children=[ v.Flex(children=[ __widgets__.sel_country, __widgets__.chk_mov_ave, __widgets__.slider_mov_ave, v.Tabs(children=[ __widgets__.tab1, __widgets__.tab2, v.TabItem(children=[__plts__.fig1.fig]), v.TabItem(children=[__plts__.fig2.fig]) ]) ]) ])
def __init__(self, cases): """ Widget definition for models. Parameters ========== cases: dict the keys of this dictionary are the name of the model, the values of this dictionary are an instance of the model. This widget is composed by a menu where you can choose the dimension and the model. This widget is also composed by a main widget where a description of the model is given. """ self.cases = cases default_category = next(iter(self.cases)) ## ## The menu ## # widget to select the model self.select_category = v.Select( items=list(self.cases.keys()), v_model=default_category, label='Category', ) self.select_model = v.Select( items=[], v_model=None, label='Model' ) self.menu = [self.select_category, self.select_model] ## ## The main ## self.description = HTML() self.tabs = v.Tabs( v_model=None, children=[ v.Tab(children=['Description']), v.TabItem(children=[self.description]), ] ) self.main = [self.tabs] # Add the widget events self.select_category.observe(self.change_category, 'v_model') self.select_model.observe(self.change_model, 'v_model') # update the category to fix the default model self.change_category(None)
def __init__(self, titles, content, **kwargs): self.background_color = "primary" self.dark = True self.tabs = [ v.Tabs( v_model=self.current, children=[ v.Tab(children=[title], key=key) for key, title in enumerate(titles) ], ) ] self.content = [ v.TabsItems( v_model=self.current, children=[ v.TabItem(children=[content], key=key) for key, content in enumerate(content) ], ) ] self.children = self.tabs + self.content link((self.tabs[0], "v_model"), (self.content[0], "v_model")) super().__init__(**kwargs)
def backend_widget(backend: Union[IBMQBackend, FakeBackend]) -> None: """Display backend information as a widget. Args: backend: Display information about this backend. """ cred = backend._credentials last_tab = vue.TabItem(children=[]) card = vue.Card( height=600, outlined=True, children=[ vue.Toolbar(flat=True, color="#002d9c", children=[ vue.ToolbarTitle(children=[ '{} @ ({}/{}/{})'.format( backend.name(), cred.hub, cred.group, cred.project) ], style_="color:white") ]), vue.Tabs(vertical=True, children=[ vue.Tab(children=['Configuration']), vue.Tab(children=['Qubits']), vue.Tab(children=['Non-local Gates']), vue.Tab(children=['Error map']), vue.Tab(children=['Job Summary']), vue.TabItem(children=[config_tab(backend)]), vue.TabItem(children=[qubits_tab(backend)]), vue.TabItem(children=[gates_tab(backend)]), vue.TabItem(children=[ iplot_error_map( backend, figsize=(None, None), as_widget=True) ]), last_tab ]) ]) # Load job data async for a bit better performance thread = threading.Thread(target=_async_job_loader, args=(last_tab, backend)) thread.start() display(card)
def __init__(self, question_model, layer_model, aoi_view): # name the tile title = cm.questionnaire.title id_ = "questionnaire_widget" # build the tiles self.constraint_tile = ConstraintTile(aoi_view, layer_model) self.priority_tile = PriorityTile() self.tiles = [self.constraint_tile, self.priority_tile] # build the content and the stepper header tab_content = [] for i, tile in enumerate(self.tiles): # add the title and content tab_content.append(v.Tab(children=[tile.get_title()])) tab_content.append(v.TabItem(children=[tile])) # build the tabs tabs = tabs = v.Tabs(class_="mt-5", fixed_tabs=True, centered=True, children=tab_content) # create a dialog widget self.dialog = cw.EditDialog(aoi_view, layer_model) # build the tile super().__init__(id_, title, inputs=[self.dialog, tabs]) # save the associated model and set the default value self.question_model = question_model self.layer_model = layer_model self.question_model.constraints = self.constraint_tile.custom_v_model self.question_model.priorities = self.priority_tile.v_model # js behaviours [ btn.on_event("click", self._open_dialog) for btn in self.priority_tile.table.btn_list ] [ c.btn.on_event("click", self._open_dialog) for c in self.constraint_tile.criterias ] self.constraint_tile.observe(self.__on_constraint, "custom_v_model") self.priority_tile.table.observe(self.__on_priority_tile, "v_model") self.dialog.observe(self.constraint_tile._update_constraints, "updated")
def _refresh(self, tab=0): _restore_endpoints_and_sessions(self.db, self.ipython_display, self.spark_controller, self.endpoints) self.create_session = CreateSessionWidget(self.spark_controller, self.ipywidget_factory, self.ipython_display, self.endpoints, self._refresh, self.state, self.db) self.add_endpoint = AddEndpointWidget(self.spark_controller, self.ipywidget_factory, self.ipython_display, self.endpoints, self._refresh, self.state, self.db) session_tab = [ v.Tab(children=['Sessions']), v.TabItem(style_='border: 1px solid lightgrey', children=[self.create_session]) ] endpoint_tab = [ v.Tab(children=['Endpoint']), v.TabItem(style_='border: 1px solid lightgrey', children=[self.add_endpoint]) ] self.tabs = v.Tabs( style_='border: 1px solid lightgrey', v_model=tab, # loads session tab when on children=session_tab + endpoint_tab) self.children = [self.tabs] for child in self.children: child.parent_widget = self
def construct_tabs(tabs_definition, slider_color=None, color=None, background_color=None, grow=True): tab_heads = [ v.TabItem(children=[tab_head]) for tab_head in tabs_definition.values() ] tab_items = [ v.Tab(children=[tab_name]) for tab_name in tabs_definition.keys() ] tabs = v.Tabs( slider_color=slider_color, color=color, background_color=background_color, grow=grow, children=tab_heads + tab_items, ) return tabs
waffle, ]), ]) tab_3 = v.Tab(children=['Multiple genotypes']) container_main = v.Container( fluid=True, class_='grid-list-md box', children=[ v.Tabs(children=[ v.Tab(children=['Data extraction']), v.Tab(children=['Single genotype']), tab_3, v.Tab(children=['Waffle']), v.TabItem(children=[tab_extraction_content]), v.TabItem(children=[tab_single_genotype_content]), v.TabItem(children=[tab_multiple_genotype_content]), v.TabItem(children=[tab_waffle_content]), ]) ]) # # ---------------------------------------------------------------- # # Link widgets - event # # ---------------------------------------------------------------- genotypes_selection_extraction.on_event('change', on_change_genotype_p4) genotypes_selection_single_genotype.on_event("change", on_change_single_genotype) genotypes_selection_waffle.on_event('change', on_change_module_waffle_genotype)
def __init__(self, test_case, known_cases): """ Widget definition for lattice Boltzmann schemes. Parameters ========== - test_case: the selected test case. - known_cases: dict A dictionary of all known cases the keys are an instance of a test case the values are a list of available lattice Boltzmann schemes for this test case This widget is composed by a menu where you can Choose the lb scheme and modify its default parameters. If you change any of the parameters, you will see a reset button to revover the default parameters of this scheme. This widget is also composed by a main widget where we have 3 tabs - the description of the lb scheme, - the properties of the lb scheme, - the equivalent equations of the lb scheme. """ self.test_case = test_case self.known_cases = known_cases self.default_cases = {c.name: c for c in known_cases[test_case.get_case()]} self.cases = {c.name: copy.copy(c) for c in known_cases[test_case.get_case()]} self.parameters = {} ## ## The menu ## default_case = list(self.cases.keys())[0] self.select_case = v.Select(items=list(self.cases.keys()), v_model=default_case, label='LBM schemes') self.panels = v.ExpansionPanels(v_model=None, children=[ParametersPanel('Show parameters')]) self.reset = v.Btn(children=['reset to default'], class_='d-none') self.menu = [self.select_case, self.panels, self.reset] ## ## The main ## self.description = Markdown() self.properties = v.Layout() self.eq_pde = v.Layout() self.tabs = v.Tabs( v_model=0, children= [ v.Tab(children=['Description']), v.Tab(children=['Properties']), v.Tab(children=['Equivalent equations']), v.TabItem(children=[self.description]), v.TabItem(children=[self.properties]), v.TabItem(children=[self.eq_pde]), ] ) self.main = [self.tabs] # populate the parameters and the description of the selected # lb scheme self.change_case(None) ## ## Widget events ## self.select_case.observe(self.change_case, 'v_model') # Allow to go back to the default parameters self.reset.on_event('click', self.reset_btn) # Check the tab id to activate the computation # of the equivalent equations or the scheme properties # since it can take time. self.tabs.observe(self.change_tab, 'v_model') # If the test case is changed, we need to list the available # lb schemes for this test. self.test_case.select_case.observe(self.change_test_case, 'v_model') # Bind each parameter to change_param # to make the reset button available if needed. self.panels.children[0].bind(self.change_param)
v.Col(col=12, sm=12, md=12, children=[ menu_plant_analyze, v.Row(children=[plot_plantscale, pie_plantscale]), ]), ]) container_main = v.Container(fluid=True, class_='grid-list-md box', children=[ v.Tabs(children=[ v.Tab(children=['Export']), v.Tab(children=['Analyses']), v.TabItem(children=[ tab_extraction_content, ]), v.TabItem(children=[tab_analyze_content]), ]) ]) # # ---------------------------------------------------------------- # # Link widgets - event # # ---------------------------------------------------------------- genotypes_selection_extraction.on_event('change', on_change_genotype_p3_t1) genotypes_selection_analyze.on_event('change', on_change_genotype_p3_t2) date_selection_analyze.on_event('change', on_change_date_p3) variable_selection_analyze.on_event('change', on_change_parameter_p3)
variable_selection_waffle, order_selection_waffle, plot_type_waffle ]) waffle = widgets.Output(layout=layout_output_wgt) tab_waffle_content = v.Row(children=[ v.Card(style_=layout_card, children=[info.p5_doc_waffle]), v.Col(col=12, sm=12, md=12, children=[ menu_plant_waffle, waffle, ]), ]) p5 = v.Tabs(children=[ v.Tab(children=['Waffle']), v.TabItem(children=[tab_waffle_content]), ]) container_main = v.Container(fluid=True, class_='grid-list-md box', children=[p5]) # # ---------------------------------------------------------------- # # Link widgets - event # # ---------------------------------------------------------------- genotypes_selection_waffle.on_event('change', on_change_node_waffle_genotype) date_selection_waffle.on_event('change', on_change_node_waffle_date) variable_selection_waffle.on_event('change', on_change_node_waffle_parameter) plot_type_waffle.on_event('change', on_change_node_plot_type) order_selection_waffle.on_event('change', on_change_node_order)
panel_files_description = v.Container(fluid=False, children=[files_description]) tab_description_content = v.Row(children=[ v.Col(cols=12, sm=3, md=3, children=[files_selection]), v.Col(cols=12, sm=7, md=9, children=[panel_files_description]) ]) container_main = v.Container( fluid=True, class_='grid-list-md box', children=[ v.Tabs(children=[ v.Tab(children=['Import Files']), v.Tab(children=['Files Description']), v.TabItem(children=[tab_MTG_content]), v.TabItem(children=[tab_description_content]) ]) ]) # # ---------------------------------------------------------------- # # Link widgets - event # # ---------------------------------------------------------------- widgets.jslink((slider_n_plant, 'v_model'), (box_n_plant, 'v_model')) files_selection.on_event('change', on_change_get_files) cb_allplants.on_event('change', on_click_allp) genotypes_selection.on_event('change', on_change_genotype) slider_n_plant.on_event('change', on_change_nbplant) box_n_plant.on_event('change', on_change_nbplant)
def backend_widget(backend: Union[IBMBackend, FakeBackend]) -> None: """Display backend information as a widget. Args: backend: Display information about this backend. """ vue.theme.dark = False if isinstance(backend, FakeBackend): cred = backend._credentials instance = to_instance_format(cred.hub, cred.group, cred.project) else: instance = backend._api_client._params.instance last_tab = vue.TabItem(children=[]) livedata = LiveDataVisualization() card = vue.Card( height=600, outlined=True, children=[ vue.Toolbar( flat=True, color="#002d9c", children=[ vue.ToolbarTitle( children=[ "{} @ ({})".format(backend.name(), instance) ], style_="color:white", ) ], ), vue.Tabs( vertical=True, children=[ vue.Tab(children=["Configuration"]), vue.Tab(children=["Qubits"]), vue.Tab(children=["Non-local Gates"]), vue.Tab(children=["Error map"]), vue.Tab(children=["Live Data"]), vue.Tab(children=["Job Summary"]), vue.TabItem(children=[config_tab(backend)]), vue.TabItem(children=[qubits_tab(backend)]), vue.TabItem(children=[gates_tab(backend)]), vue.TabItem(children=[ iplot_error_map( backend, figsize=(None, None), as_widget=True) ]), vue.TabItem(children=[ iplot_error_map( backend, figsize=(None, None), as_widget=True) ]), vue.TabItem(children=[ livedata.create_visualization( backend, figsize=(11, 9), show_title=False) ]), last_tab, ], ), ], ) # Load job data async for a bit better performance thread = threading.Thread(target=_async_job_loader, args=(last_tab, backend)) thread.start() display(card)
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)
def __init__(self, cases, default_case): """ Widget definition for test cases. Parameters ========== - cases: dict the keys of this dictionary are the name of the test case, the values of this dictionary are an instance of the test case. - default_case: str one of the keys found into the dictionary cases. This widget is composed by a menu where you can choose the test case and modify its default parameters. If you change any of the parameters, you will see a reset button to revover the default parameters of this case. This widget is also composed by a main widget where a description of the test cases is given and a plot of the reference solution if it exists. """ self.default_cases = cases # make a copy to not modify the input instances self.cases = copy.deepcopy(cases) self.parameters = {} ## ## The menu ## # widget to select the test case self.select_case = v.Select(items=list(self.cases.keys()), v_model=default_case, label='Test cases') self.panels = v.ExpansionPanels( v_model=None, children=[ParametersPanel('Show parameters')]) self.reset = v.Btn(children=['reset to default'], class_='d-none') self.menu = [self.select_case, self.panels, self.reset] ## ## The main ## self.description = Markdown() plt.ioff() self.fig = plt.figure(figsize=(12, 6)) self.fig.canvas.header_visible = False tabs_content = [ v.TabItem(children=[self.description]), v.TabItem(children=[self.fig.canvas]) ] self.tabs = v.Tabs(v_model=None, children=[ v.Tab(children=['Description']), v.Tab(children=['Reference results']) ] + tabs_content) self.main = [self.tabs] # Add the widget events self.reset.on_event('click', self.reset_btn) self.select_case.observe(self.change_case, 'v_model') self.panels.children[0].bind(self.change_param) self.change_case(None)
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", children=[ toolbar, v.Container( fluid=True, mt_3=True, children=[v.Layout(children=[v.Flex(children=[tabs])])]) ])
tab_2d_content = v.Row(children=[ v.Card(style_=layout_card, children=[info.p2_doc_visu2d]), v.Col(col=12, sm=12, md=12, children=[row_param2d, panel_2d]) ]) # Instantiate tab 3d here to link it to an event tab_3d = v.Tab(children=['3d Visualization']) container_main = v.Container(fluid=True, class_='grid-list-md box', children=[ v.Tabs(children=[ v.Tab(children=['2d Visualization']), tab_3d, v.TabItem(children=[tab_2d_content]), v.TabItem(children=[tab_3d_content]), ]) ]) # # ---------------------------------------------------------------- # # Link widgets - event # # ---------------------------------------------------------------- genotype_selection_3d.on_event("change", on_change_3d) parameter_color.on_event("change", on_change_3d) genotype_selection_2d.on_event("change", on_change_geno_2d) id_selection_2d.on_event("change", on_change_id_2d) tab_3d.on_event('change', on_change_tab_3d)