Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 469e094

Browse files
committed
whats new note
1 parent 895bd46 commit 469e094

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)