☰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

Passing an argument to a callback

Community Support
albertino87
albertino87

Hi,
I have two TextInput widgets that call the same function the only difference is which of the 2 Textinput is calling it which I can easily achieve by passing an additional argument to the callback. Something like:

self._labelfilter = TextInput()
self._labelfilter.on_change('value_input', self._apply_filter('label'))

Is it possible to do this, or I have to write 2 different callbacks with a 3rd function for the common code?
Many thanks

⌁   Link to post
Bryan
Bryan

The function passed to on_change always has to have the fixed set of known parameters. That’s generally how callback-based frameworks have to be, since it is the framework that executes the callback function, not you.

However, you can define a function that takes extra parameters and then use the standard library functools.partial to “bake in” values for the additional arguments before you call on_change (and specifically, you can bake in different values for different calls to on_change).

⌁   Link to post

End of archived discussion · Replies are disabled