
I started to try doing custom extensions for tools. Is there a way to get the custom tool to merge in the gridplot() toolbar when merge_tool = True?
In this example I just extend the reset tool so it prints something in the console when clicked. It works fine when i show the figure alone or when the gridplot toolbar has merge_tool = False.
from bokeh.io import show
from bokeh.plotting import figure
from bokeh.models import Tool
from bokeh.layouts import gridplot
reset_code = “”"
import * as p from “core/properties”
import {ResetTool,ResetToolView} from “models/tools/actions/reset_tool”
export class NewResetView extends ResetToolView
NewResetView::doit = →
@plot_view.clear_state()
@plot_view.reset_range()
@plot_view.reset_selection()
console.log ‘TEST’
if @model.reset_size
return @plot_view.reset_dimensions()
return
export class NewReset extends ResetTool
default_view : NewResetView
type : “ResetTool”
tool_name : “NewReset”
icon : “bk-tool-icon-reset”
“”"
class NewReset(Tool):
implementation = reset_code
fig = figure()
fig.scatter(x=range(10),y=range(10))
fig.toolbar.tools += [NewReset()]
grid = gridplot([[fig]])
show(fig)
grid.children[0].merge_tools = False # if True, the new tool does not show up
#show(grid)
``
