Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 895bd46 commit 469e094Copy full SHA for 469e094
1 file changed
doc/release/next_whats_new/callback_registry_disconnect_func.rst
@@ -0,0 +1,20 @@
1
+``CallbackRegistry.disconnect_func`` to disconnect callbacks by function
2
+-------------------------------------------------------------------------
3
+
4
+`.CallbackRegistry` now has a `~.CallbackRegistry.disconnect_func` method that
5
+allows disconnecting a callback by passing the signal and function directly,
6
+instead of needing to track the callback ID returned by
7
+`~.CallbackRegistry.connect`.
8
9
+.. code-block:: python
10
11
+ from matplotlib.cbook import CallbackRegistry
12
13
+ def my_callback(event):
14
+ print(event)
15
16
+ callbacks = CallbackRegistry()
17
+ callbacks.connect('my_signal', my_callback)
18
19
+ # Disconnect by function reference instead of callback ID
20
+ callbacks.disconnect_func('my_signal', my_callback)
0 commit comments