Changing icon and tooltip of tool

Hello there,

I have got a question regarding the tooltip and icon of tools (in particularly a BoxSelectTool). What I want is to have a specific name to show instead of “Box Select (x-axis)”

Is that possible? Do I have to do something similar to this?

Many thangs in advance,

Yep. Since the tooltip is defined in TypeScript and doesn’t use any model attributes, you have to write some TypeScript/JavaScript to achieve that:

from import show
from bokeh.models import PanTool
from bokeh.plotting import figure

class RenamedPanTool(PanTool):
    # language=JavaScript
    __implementation__ = """
        import {PanTool} from "models/tools/gestures/pan_tool";
        export class RenamedPanTool extends PanTool {
            // Doesn't work for `PanTool` in particular because
            // it doesn't use it in its `.tooltip` getter override.
            tool_name = 'Renamed pan tool'
            // But we can use this instead.
            get tooltip() {
                return this.tool_name;

pt = RenamedPanTool()
p = figure(tools=[pt])
p.line([0, 1], [0, 1])


Thanks for the help! However, I get some strange error message with this code

class RenamedBoxSelectTool(BoxSelectTool):
    # language=JavaScript
    __implementation__ = """
        import {BoxSelectTool} from "models/tools/all";
        export class RenamedBoxSelectTool extends BoxSelectTool {
            tool_name = "Mark Peak"
            get tooltip() {
                return this.tool_name;

The error message I get is this one. I am really not sure why. I am still on bokeh 1.4.0.

BokehDeprecationWarning: CoffeeScript support is deprecated and will be removed in an eventual 2.0 release. Use JavaScript or TypeScript directly instead.
Compilation failed:

[stdin]:7:17: error: unexpected return
                return this.tool_name; 

I guess you’re not using 2.0, which has been released? If so, just wrap the code in TypeScript(...) from bokeh.util.compiler.

I know above I’ve left the # language=JavaScript comment for IDEA (which uses it to enable syntax highlighting within the string), but it seems that my code doesn’t work with JavaScript. In order to make it work with JavaScript (which also makes the compilation time faster), you have to replace the line tool_name = "Mark Peak" with:

static tool_name = 'Renamed pan tool'
static __name__ = 'RenamedPanTool'

You still have to wrap it all in JavaScript(...) though.