-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add @QtCore.Slot()
decorations to NavigationToolbar2QT
#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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Unfortunately, I haven't found a workaround for https://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.Slot
def foo(self):
return super().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 in self.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()
def home(self, *args):
return super().home(*args)
@QtCore.Slot()
def back(self, *args):
return super().back(*args)
@QtCore.Slot()
def forward(self, *args):
return super().forward(*args)
@QtCore.Slot()
def pan(self, *args):
return super().pan(*args)
@QtCore.Slot()
def zoom(self, *args):
return super().zoom(*args)
@QtCore.Slot()
def configure_subplots(self, *args):
return super().configure_subplots(*args)
@QtCore.Slot()
def edit_parameters(self, *args):
return super().edit_parameters(*args)
@QtCore.Slot()
def save_figure(self, *args):
return super().save_figure(*args)
and this works for home
, back
and forward
- but not for the others. Irrespective of the position inside NavigationToolbar2QT
, and irrespective of the order of the functions. This is with PySide6-Essentials
v6.6.0.
I put this code into https://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