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
|
proxy = _weak_or_strong_ref(func, self._remove_proxy) |
|
if proxy in self._func_cid_map[signal]: |
|
return self._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 _ in range(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:
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 in b6a6414
This seems not so nice and a bit surprising (as in #15785 (comment)); we should deprecate that behavior and either
keep_duplicates={None,True,False}where None (default) raises an exception for duplicates, True keeps them, False drops them.Code for reproduction
and click on the canvas.
Actual outcome
The event is printed once.
Expected outcome
The event is printed twice.
Matplotlib version
import matplotlib; print(matplotlib.__version__)): HEAD (3.4.x+)print(matplotlib.get_backend())): any