☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Deactivating hover tool in python callback

Community Support
Sebastien_Roche
Sebastien_Roche

Is there a way to access the active attribute of a hovertool from a python callback? Just like what that JS callback does:

from bokeh.models import CustomJS, Button
from bokeh.plotting import figure
from bokeh.layouts import gridplot
from bokeh.io import show

fig = figure(tools=‘hover’)

hover = fig.toolbar.tools[0]

button = Button(label=‘HoverOnOff’,width=150)

button.callback = CustomJS(args={‘hover’:hover},code=“hover.active = !hover.active;”)

x = range(10)
fig.scatter(x,x)

grid = gridplot([[button,fig]])

show(grid)

``

⌁   Link to post
Mateusz_Paprocki2
Mateusz_Paprocki2

Hi,

···

On Mon, Jun 18, 2018 at 4:18 PM, Sébastien Roche sebastienroche11@gmail.com wrote:

Is there a way to access the active attribute of a hovertool from a python callback? Just like what that JS callback does:

Tool.active is an internal property (to bokehjs), so no. However, I’m not sure exactly why it is this way. I don’t see any reason for not allowing users to configure active tools programmatically. Perhaps this has something to do with initialization of toolbars, which is pretty complicated. Maybe Bryan will have some more concrete feedback. Otherwise this seems something that could be improved.

Mateusz

from bokeh.models import CustomJS, Button
from bokeh.plotting import figure
from bokeh.layouts import gridplot
from bokeh.io import show

fig = figure(tools=‘hover’)

hover = fig.toolbar.tools[0]

button = Button(label=‘HoverOnOff’,width=150)

button.callback = CustomJS(args={‘hover’:hover},code=“hover.active = !hover.active;”)

x = range(10)
fig.scatter(x,x)

grid = gridplot([[button,fig]])

show(grid)

``

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a1e07f09-668e-413a-a637-83023771d448%40continuum.io.

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

⌁   Link to post
Bryan
Bryan

Hi,

I don't recall offhand, I'd chalk it up to history at this point. As Mateusz said, toolbar interaction handling is one of the more gorpy and complicated parts to the code base. Lots of surprising side cases, even before you get to things like coalescing toolbars on grid plots. My guess is at the time I just didn't have the bandwidth to figure out how to make all that work, and make things user configurable in a consistent, working way at the same time. It's possibly something we could revisit. The next appropriate step would be a GH issue for the feature request.

Thanks,

Bryan

···

On Jun 18, 2018, at 09:16, Mateusz Paprocki <mpaprocki@anaconda.com> wrote:

Hi,

On Mon, Jun 18, 2018 at 4:18 PM, Sébastien Roche <sebastienroche11@gmail.com> wrote:
Is there a way to access the active attribute of a hovertool from a python callback? Just like what that JS callback does:

Tool.active is an internal property (to bokehjs), so no. However, I'm not sure exactly why it is this way. I don't see any reason for not allowing users to configure active tools programmatically. Perhaps this has something to do with initialization of toolbars, which is pretty complicated. Maybe Bryan will have some more concrete feedback. Otherwise this seems something that could be improved.

Mateusz

from bokeh.models import CustomJS, Button
from bokeh.plotting import figure
from bokeh.layouts import gridplot
from bokeh.io import show

fig = figure(tools='hover')

hover = fig.toolbar.tools[0]

button = Button(label='HoverOnOff',width=150)

button.callback = CustomJS(args={'hover':hover},code="hover.active = !hover.active;")

x = range(10)
fig.scatter(x,x)

grid = gridplot([[button,fig]])

show(grid)

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/a1e07f09-668e-413a-a637-83023771d448%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANFzp8jqdyz9ybeOe9YXkkZ7r0hRqxhxy9ARaFa-m9Kv3BfXRg%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled