Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Description
Bug report
Bug summary
Currently, if a same function is connected twice to the same signal and same callbackregisry, the second connection is silently dropped, per
matplotlib/lib/matplotlib/cbook/__init__.py
Lines 208 to 210 inb6a6414
proxy=_weak_or_strong_ref(func,self._remove_proxy) | |
ifproxyinself._func_cid_map[signal]: | |
returnself._func_cid_map[signal][proxy] |
This seems not so nice and a bit surprising (as in#15785 (comment)); we should deprecate that behavior and either
- (preferred) just always perform the connection, even if duplicated; it's the user's job to keep track of duplicates if they want; or
- (less preferred) add something like
keep_duplicates={None,True,False}
where None (default) raises an exception for duplicates, True keeps them, False drops them.
Code for reproduction
for_inrange(2):gcf().canvas.mpl_connect("button_press_event",print)show()
and click on the canvas.
Actual outcome
The event is printed once.
Expected outcome
The event is printed twice.
Matplotlib version
- Operating system: linux
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): HEAD (3.4.x+) - Matplotlib backend (
print(matplotlib.get_backend())
): any - Python version: 39
- Jupyter version (if applicable):
- Other libraries: