merge custom tool in grid layout

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)

``

It seems like I needed to give the new tool a new type too. The new reset tool was actually merged with the default reset tool in a reset button with name “Reset”

If there is not default reset tool in the grid, the “NewReset” tools will be merged together in a reset button with name “NewReset”

If I just do

type:“NewResetTool”

``

then they will be merged as expected and there will be both a reset button with name “NewReset”, and a reset button with name “Reset” for the default tool

type must be the same as model name. We would auto-generate this if only any languages we use supported macros.

···

On Sep 6, 2017 16:07, “Sébastien Roche” [email protected] wrote:

It seems like I needed to give the new tool a new type too. The new reset tool was actually merged with the default reset tool in a reset button with name “Reset”

If there is not default reset tool in the grid, the “NewReset” tools will be merged together in a reset button with name “NewReset”

If I just do

type:“NewResetTool”

``

then they will be merged as expected and there will be both a reset button with name “NewReset”, and a reset button with name “Reset” for the default tool

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/84fbe5f1-d962-4896-93aa-eac5bd47caa8%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.