Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
QuLogic merged 3 commits intomatplotlib:mainfrombersbersbers:fix-27214
Nov 18, 2023
Merged

Add@QtCore.Slot() decorations toNavigationToolbar2QT#27215

QuLogic merged 3 commits intomatplotlib:mainfrombersbersbers:fix-27214
Nov 18, 2023

Conversation

bersbersbers
Copy link
Contributor

PR summary

Add@QtCore.Slot() decorations toNavigationToolbar2QT to suppress "Registering dynamic slot" warnings.Closes#27214.

PR checklist

Copy link

@github-actionsgithub-actionsbot left a 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.

@bersbersbers
Copy link
ContributorAuthor

Unfortunately, I haven't found a workaround forhttps://bugreports.qt.io/browse/PYSIDE-2512 that does not use a lambda. Should I add# noqa: E731 for this one?

@anntzer
Copy link
Contributor

A similar workaround would be to wrap with functools.partial, i.e.QtCore.Slot()(functools.partial(getattr(self, callback))) (which all fits in a single line).

bersbersbers reacted with thumbs up emoji

@bersbersbers
Copy link
ContributorAuthor

@anntzer thanks, that's a neat idea that works locally for me. Updated the PR.

@bersbersbers
Copy link
ContributorAuthor

Woohoo, all green. That wasn't too bad, just had to add somefunctools.wraps as well for PyQt.

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)
Copy link
Member

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!

Copy link
ContributorAuthor

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...

Copy link
ContributorAuthor

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.

Copy link
Member

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....).

Copy link
Contributor

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.

@QuLogicQuLogic merged commitf533687 intomatplotlib:mainNov 18, 2023
@QuLogic
Copy link
Member

Thanks@bersbersbers! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@anntzeranntzeranntzer approved these changes

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@QuLogicQuLogicQuLogic approved these changes

Assignees
No one assigned
Labels
Projects
Milestone
v3.9.0
Development

Successfully merging this pull request may close these issues.

[Bug]:NavigationToolbar2QT should use@Slot annotation
5 participants
@bersbersbers@anntzer@QuLogic@tacaswell@melissawm

[8]ページ先頭

©2009-2025 Movatter.jp