Passing an argument to a callback

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

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).