param.parameterized.Parameters.unwatch#

Parameters.unwatch(watcher: Watcher) None[source]#

Remove a watcher from this object’s list of registered watchers.

This method unregisters a previously registered Watcher object, effectively stopping it from being triggered by events on the associated parameters. Calling unwatch with an already unregistered watcher is a no-op.

Parameters:

watcher (Watcher) – The Watcher object to remove. This should be an object returned by a previous call to watch() or watch_values().

See also

watch

Registers a new watcher to observe parameter changes.

watch_values

Registers a watcher specifically for value changes.

Examples

>>> import param
>>> class MyClass(param.Parameterized):
...     a = param.Number(default=1)
...
...     def callback(self, event):
...         print(f"Triggered by {event.name}")
...
>>> instance = MyClass()

Add a watcher:

>>> watcher = instance.param.watch(instance.callback, ['a'])

Trigger the watcher:

>>> instance.a = 10
Triggered by a

Remove the watcher:

>>> instance.param.unwatch(watcher)

No callback is triggered after removing the watcher:

>>> instance.a = 20  # No output

Calling unwatch() again has no effect:

>>> instance.param.unwatch(watcher)