def test_expand_param_subobject_into_column(document, comm): class Test(param.Parameterized): a = param.Parameter() test = Test(a=Test(name='Nested')) column = Column() test_pane = Pane(test, subobject_layout=column, _temporary=True) layout = Row(test_pane, column) model = layout._get_model(document, comm=comm) toggle = model.children[0].children[2] assert isinstance(toggle, Toggle) # Expand subpane test_pane._widgets['a'][1].active = True assert len(model.children) == 2 subpanel = column.objects[0] row = model.children[1] assert 'instance' in subpanel._callbacks assert isinstance(row, BkColumn) assert len(row.children) == 1 box = row.children[0] assert isinstance(box, BkWidgetBox) assert len(box.children) == 2 div, widget = box.children assert div.text == '<b>Nested</b>' assert isinstance(widget, BkTextInput) # Collapse subpanel test_pane._widgets['a'][1].active = False assert len(row.children) == 0 assert subpanel._callbacks == {}
def __init__(self, **params): super(TreeViewCheckBox, self).__init__(**params) self.select_all = params.get('select_all', "") self.select_options = params.get('select_options', "") self.option_descriptions = params.get('description', []) TreeViewCheckBox.box_size = max( [len(word) for word in self.select_options] + [len(self.select_all), TreeViewCheckBox.box_size]) * 10 self.all_selector = Checkbox(name=self.select_all, value=True) self.all_selector.param.watch(self._update_all, 'value') self.selected_options = CheckBoxGroup( name='Checkbox Group', value=self.select_options, options=self.select_options, ) self.selected_options.param.watch(self._update_selected_options, 'value') self.all_drop = Checkbox(css_classes=['chck-custom']) self.all_drop.param.watch(self._show_drop_down, 'value') # Define Layout self._composite[:] = [ #HTML(self._css_injection, width=0, height=0, margin=0, sizing_mode="fixed"), Column(Row(Row(self.all_selector, max_width=self.box_size), self.all_drop), max_width=self.box_size) ]
def _fast_button_card(): button = Button(name="Click me", button_type="primary") button.param.name.precedence = 0 button.param.clicks.precedence = 0 button.param.disabled.precedence = 0 button.param.button_type.precedence = 0 button_parameters = [ "name", "button_type", "clicks", "disabled", "width", "height", "sizing_mode", ] settings = Param( button, parameters=button_parameters, show_name=False, sizing_mode="stretch_width", ) return Column( HTML("<h2>Button</h2>"), button, HTML("<h3>Parameters</h3>"), settings, sizing_mode="stretch_both", )
def test_holoviews_with_widgets_not_shown(document, comm): hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['X', 'Y']) hv_pane = HoloViews(hmap, show_widgets=False) layout_obj = Column(hv_pane, hv_pane.widget_box) layout = layout_obj.get_root(document, comm) model = layout.children[0] assert len(hv_pane.widget_box.objects) == 2 assert hv_pane.widget_box.objects[0].name == 'X' assert hv_pane.widget_box.objects[1].name == 'Y' assert hv_pane._models[layout.ref['id']][0] is model hmap = hv.HoloMap({(i, chr(65+i)): hv.Curve([i]) for i in range(3)}, kdims=['A', 'B']) hv_pane.object = hmap assert len(hv_pane.widget_box.objects) == 2 assert hv_pane.widget_box.objects[0].name == 'A' assert hv_pane.widget_box.objects[1].name == 'B'
def test_gallery(): """Test that we can see the gallery page""" page_outlet = Column(sizing_mode="stretch_width") page = gallery.Gallery( page_outlet=page_outlet, apps_in_gallery=APPS_IN_GALLERY, ).view() page_outlet[:] = [page] return TestApp( test_gallery, page_outlet, )
def layout(self, **kwargs): """ Returns a layout of the widgets and output arranged according to the center and widget location specified in the interactive call. """ widget_box = self.widgets() panel = self.output() loc = self._loc if loc in ('left', 'right'): widgets = Column(VSpacer(), widget_box, VSpacer()) elif loc in ('top', 'bottom'): widgets = Row(HSpacer(), widget_box, HSpacer()) elif loc in ('top_left', 'bottom_left'): widgets = Row(widget_box, HSpacer()) elif loc in ('top_right', 'bottom_right'): widgets = Row(HSpacer(), widget_box) elif loc in ('left_top', 'right_top'): widgets = Column(widget_box, VSpacer()) elif loc in ('left_bottom', 'right_bottom'): widgets = Column(VSpacer(), widget_box) center = self._center if not widgets: if center: components = [HSpacer(), panel, HSpacer()] else: components = [panel] elif center: if loc.startswith('left'): components = [widgets, HSpacer(), panel, HSpacer()] elif loc.startswith('right'): components = [HSpacer(), panel, HSpacer(), widgets] elif loc.startswith('top'): components = [ HSpacer(), Column(widgets, Row(HSpacer(), panel, HSpacer())), HSpacer() ] elif loc.startswith('bottom'): components = [ HSpacer(), Column(Row(HSpacer(), panel, HSpacer()), widgets), HSpacer() ] else: if loc.startswith('left'): components = [widgets, panel] elif loc.startswith('right'): components = [panel, widgets] elif loc.startswith('top'): components = [Column(widgets, panel)] elif loc.startswith('bottom'): components = [Column(panel, widgets)] return Row(*components, **kwargs)
def test_title_awesome(): """Test that we can write awesome title with the awesome badge - one with additional text - one with additional 'Test' text """ title_none = title_awesome("") title_test = title_awesome("Test") Column( title_none, title_test, sizing_mode="stretch_width", ).servable()