Throttled update for Selections

Hey, is there a way to throttle the update of a selection. For example if I have a lasso_select and start selecting points than with every new selected or unselected point the callback will be triggered (simple example below). What I want to achieve is that the callback is trigger after a mouse up when I am done with the selection. Is there a way to achieve this?

import pandas as pd
from bokeh.plotting import show, figure
from bokeh.models import ColumnDataSource

source = ColumnDataSource(pd.DataFrame({"x": [1,2], "y": [1,2]}))
source.selected.on_change("indices", lambda attr, old, new: print("test"))

p = figure(tools="lasso_select")
p.scatter("x", "y", source=source)

show(p)

You can set the select_every_mousemove property on the tool to False. That will cause selections to only register only at the end (i.e. on mouseup).

p.select_one(LassonSelectTool).select_every_mousemove = False
1 Like

Thank you very much, this solved the problem.