Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Add@QtCore.Slot()
decorations toNavigationToolbar2QT
#27215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join uson gitter for real-time discussion.
For details on testing, writing docs, and our review process, please seethe developer guide
We strive to be a welcoming and open project. Please follow ourCode of Conduct.
Unfortunately, I haven't found a workaround forhttps://bugreports.qt.io/browse/PYSIDE-2512 that does not use a lambda. Should I add |
A similar workaround would be to wrap with functools.partial, i.e. |
@anntzer thanks, that's a neat idea that works locally for me. Updated the PR. |
Woohoo, all green. That wasn't too bad, just had to add some Will you require a test for the emitted warning as well, or is it enough for all existing functionality to remain working? |
slot = getattr(self, callback) | ||
# https://bugreports.qt.io/browse/PYSIDE-2512 | ||
slot = functools.wraps(slot)(functools.partial(slot)) | ||
slot = QtCore.Slot()(slot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If this indeed portable this way, can we just decorate the methods directly? Even if we have to add a bunch of methods like
@QtCore.Slotdeffoo(self):returnsuper().foo()
that seems better than doing the multi-layered meta-programming here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes, can do. A considerable amount of meta-programming is still done in the loop just around the snippet, so maybe a test is needed to make sure that all functions inself.toolitems
have been decorated...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Wow, that's interesting. I tried adding
@QtCore.Slot()defhome(self,*args):returnsuper().home(*args)@QtCore.Slot()defback(self,*args):returnsuper().back(*args)@QtCore.Slot()defforward(self,*args):returnsuper().forward(*args)@QtCore.Slot()defpan(self,*args):returnsuper().pan(*args)@QtCore.Slot()defzoom(self,*args):returnsuper().zoom(*args)@QtCore.Slot()defconfigure_subplots(self,*args):returnsuper().configure_subplots(*args)@QtCore.Slot()defedit_parameters(self,*args):returnsuper().edit_parameters(*args)@QtCore.Slot()defsave_figure(self,*args):returnsuper().save_figure(*args)
and this works forhome
,back
andforward
- but not for the others. Irrespective of the position insideNavigationToolbar2QT
, and irrespective of the order of the functions. This is withPySide6-Essentials
v6.6.0.
I put this code intohttps://github.com/bersbersbers/matplotlib-27214/commit/a3d97f8eb2b40a46fe2d4fc4cf60f9d631fd3cf2 if anyone wants to try it themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
My guess is multiple inheritance is related, but do not have a good theory as to why (other than general suspicion that MI always causes problems....).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If the metaprogramming approach works then let's just stick to it.
Thanks@bersbersbers! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again. |
PR summary
Add
@QtCore.Slot()
decorations toNavigationToolbar2QT
to suppress "Registering dynamic slot" warnings.Closes#27214.PR checklist