Add a callback function that will be called whenever one of the `.Artist`'s properties changes. Parameters ---------- func : callable The callback function. It must have the signature:: def func(artist: Artist) -> Any
(self, func)
| 402 | return bbox |
| 403 | |
| 404 | def add_callback(self, func): |
| 405 | """ |
| 406 | Add a callback function that will be called whenever one of the |
| 407 | `.Artist`'s properties changes. |
| 408 | |
| 409 | Parameters |
| 410 | ---------- |
| 411 | func : callable |
| 412 | The callback function. It must have the signature:: |
| 413 | |
| 414 | def func(artist: Artist) -> Any |
| 415 | |
| 416 | where *artist* is the calling `.Artist`. Return values may exist |
| 417 | but are ignored. |
| 418 | |
| 419 | Returns |
| 420 | ------- |
| 421 | int |
| 422 | The observer id associated with the callback. This id can be |
| 423 | used for removing the callback with `.remove_callback` later. |
| 424 | |
| 425 | See Also |
| 426 | -------- |
| 427 | remove_callback |
| 428 | """ |
| 429 | # Wrapping func in a lambda ensures it can be connected multiple times |
| 430 | # and never gets weakref-gc'ed. |
| 431 | return self._callbacks.connect("pchanged", lambda: func(self)) |
| 432 | |
| 433 | def remove_callback(self, oid): |
| 434 | """ |