Disconnect a callback. Parameters ---------- cid_or_func : int or callable If an int, disconnect the callback with that connection id. If a callable, disconnect that function from signals. signal : optional Only used when
(self, cid_or_func, *, signal=None)
| 336 | |
| 337 | @_api.rename_parameter("3.11", "cid", "cid_or_func") |
| 338 | def disconnect(self, cid_or_func, *, signal=None): |
| 339 | """ |
| 340 | Disconnect a callback. |
| 341 | |
| 342 | Parameters |
| 343 | ---------- |
| 344 | cid_or_func : int or callable |
| 345 | If an int, disconnect the callback with that connection id. |
| 346 | If a callable, disconnect that function from signals. |
| 347 | signal : optional |
| 348 | Only used when *cid_or_func* is a callable. If given, disconnect |
| 349 | the function only from that specific signal. If not given, |
| 350 | disconnect from all signals the function is connected to. |
| 351 | |
| 352 | Notes |
| 353 | ----- |
| 354 | No error is raised if such a callback does not exist. |
| 355 | """ |
| 356 | if isinstance(cid_or_func, int): |
| 357 | if signal is not None: |
| 358 | raise ValueError( |
| 359 | "signal cannot be specified when disconnecting by cid") |
| 360 | for sig, proxy in self._func_cid_map: |
| 361 | if self._func_cid_map[sig, proxy] == cid_or_func: |
| 362 | break |
| 363 | else: # Not found |
| 364 | return |
| 365 | self._remove_proxy(sig, proxy) |
| 366 | elif signal is not None: |
| 367 | # Disconnect from a specific signal |
| 368 | proxy = _weak_or_strong_ref(cid_or_func, None) |
| 369 | self._remove_proxy(signal, proxy) |
| 370 | else: |
| 371 | # Disconnect from all signals |
| 372 | proxy = _weak_or_strong_ref(cid_or_func, None) |
| 373 | for sig, prx in list(self._func_cid_map): |
| 374 | if prx == proxy: |
| 375 | self._remove_proxy(sig, proxy) |
| 376 | |
| 377 | def process(self, s, *args, **kwargs): |
| 378 | """ |
nothing calls this directly
no test coverage detected