def test_toolbar_box_with_no_children_does_not_raise_a_bokeh_warning(mock__show_with_state: MagicMock) -> None: # This is the normal way a ToolbarBox would be instantiated for example in # a gridplot. So we don't want to worry people with warnings. The children # for the ToolbarBox are created on the JS side. tb_box = ToolbarBox() with mock.patch('bokeh.core.validation.check.log') as mock_logger: check_integrity([tb_box]) assert mock_logger.warning.call_count == 0
def test_toolbar_box_properties(): tb_box = ToolbarBox() assert tb_box.toolbar_location == "right"
def test_toolbar_box_is_instance_of_LayoutDOM(): tb_box = ToolbarBox() assert isinstance(tb_box, LayoutDOM)
def test_toolbar_box_properties(): tb_box = ToolbarBox() assert tb_box.logo == "normal" assert tb_box.toolbar_location == "right" assert tb_box.tools == [] assert tb_box.merge_tools is True
def test_toolbar_box_is_instance_of_box(): tb_box = ToolbarBox() assert isinstance(tb_box, Box)
def ToolBar(self): toolBarBoxes = [] for figure in self.figures: toolBarBoxes.append( ToolbarBox(toolbar=figure.toolbar, toolbar_location="above")) return toolBarBoxes
def ToolBar(self): """Barc Tool Bar """ toolBarList = [] # For each figure supplied (if multiple) for i, figure in enumerate(self.figures): barc_tools = [] figure.add_tools( bokeh.models.tools.UndoTool(tags=['barcundo']), bokeh.models.tools.RedoTool(tags=['barcredo']), bokeh.models.tools.ZoomInTool(tags=['barczoom_in']), bokeh.models.tools.ZoomOutTool(tags=['barczoom_out']), bokeh.models.tools.PanTool(tags=['barcpan']), bokeh.models.tools.WheelZoomTool(tags=['barcwheelzoom']), bokeh.models.tools.BoxZoomTool(tags=['barcboxzoom']), bokeh.models.tools.ResetTool(tags=['barcreset']), self.boxEdit(), self.polyLine(), self.polyDraw(), self.windBarb()) for glyph in self.allglyphs: glyphtool = self.textStamp(chr(glyph)) barc_tools.append(glyphtool) figure.add_tools(*barc_tools) toolBarList.append( ToolbarBox(toolbar=figure.toolbar, toolbar_location=None, visible=False, css_classes=['barc_g%d' % i])) # standard buttons toolBarBoxes = bokeh.models.layouts.Column(children=toolBarList) self.toolBarBoxes = toolBarBoxes buttonspec1 = { 'undo': 'undo', 'redo': 'redo', 'zoom_in': 'zoom_in', 'zoom_out': 'zoom_out', 'pan': "move", 'boxzoom': "boxzoom", 'wheelzoom': "wheelzoom", 'reset': 'reset', 'box_edit': 'box_edit', 'freehand': "freehand", 'poly_draw': 'poly_draw', 'poly_edit': 'poly_edit', 'textbox': 'textbox', } buttonsubspec1 = { 'freehand': "freehand", 'poly_draw': 'poly_draw', 'poly_edit': 'poly_edit', 'textbox': 'textbox', } buttons1 = [] for each in buttonspec1: button = bokeh.models.widgets.Button( label=buttonspec1[each], css_classes=[ 'barc-' + buttonspec1[each] + '-button', 'barc-button' ], aspect_ratio=1, margin=(0, 0, 0, 0)) if each in buttonsubspec1: button.js_on_event( ButtonClick, bokeh.models.CustomJS(args=dict(buttons=list( toolBarBoxes.select({'tags': ['barc' + each]}))), code=""" var each; for(each of buttons) { each.active = true; } """)) buttons1.append(button) buttonspec2 = { 'windbarb': "windbarb", 'coldfront': "cold", 'warmfront': "warm", 'occludedfront': "occluded", 'stationaryfront': "stationary", } buttons2 = [] for each in buttonspec2: button = bokeh.models.widgets.Button( label=buttonspec2[each], css_classes=[ 'barc-' + buttonspec2[each] + '-button', 'barc-button' ], aspect_ratio=1, margin=(0, 0, 0, 0)) button.js_on_event( ButtonClick, bokeh.models.CustomJS(args=dict( buttons=list(toolBarBoxes.select({'tags': ['barc' + each]}))), code=""" var each; for(each of buttons) { each.active = true; } """)) buttons2.append(button) self.barcTools.children.append(bokeh.layouts.grid(buttons1, ncols=7)) self.barcTools.children.append(bokeh.layouts.grid(buttons2, ncols=5)) self.glyphrow = bokeh.layouts.grid(self.display_glyphs(), ncols=5) self.barcTools.children.append(self.glyphrow) self.barcTools.children.extend([self.dropDown]) self.barcTools.children.extend([ self.colourPicker, self.widthPicker, self.saveButton, self.saveArea ]) self.barcTools.children.append(toolBarBoxes) return self.barcTools