Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add thumbnail for embedding in user interfaces examples#31365

Merged
timhoffm merged 2 commits intomatplotlib:mainfrom
buddy0452004:add-thumbnail-embedding-tk
Apr 22, 2026
Merged

Add thumbnail for embedding in user interfaces examples#31365
timhoffm merged 2 commits intomatplotlib:mainfrom
buddy0452004:add-thumbnail-embedding-tk

Conversation

@buddy0452004
Copy link
Copy Markdown
Contributor

@buddy0452004 buddy0452004 commented Mar 24, 2026

Adds thumbnails for multiple sgskip examples in the user_interfaces gallery that were missing preview images.

Examples covered:

  • embedding_in_tk_sgskip.py (Tkinter)
  • embedding_in_qt_sgskip.py (PyQt5)
  • embedding_webagg_sgskip.py (WebAgg)
  • toolmanager_sgskip.py
  • svg_histogram_sgskip.py
  • svg_tooltip_sgskip.py
  • canvasagg.py

Each example has a screenshot saved in images/ and sphinx_gallery_thumbnail_path added to its docstring.

Closes #17479

AI Disclosure

No AI used.

PR Checklist

  • "closes #0000" is in the body of the PR description to link the related issue
  • [N/A] new and changed code is tested
  • [N/A] Plotting related features are demonstrated in an example
  • [N/A] New Features and API Changes are noted with a directive and release note
  • [N/A] Documentation complies with general and docstring guidelines

@github-actions
Copy link
Copy Markdown

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. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

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.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Mar 25, 2026

While these images are displaying what the Matplotlib side of the examples produce, I don't think these are good indicators of what the examples are. The point of the embedding examples is that they are in Tk (or Qt or whatever); if we wanted just the Matplotlib part, these would be regular examples without any of that extra stuff.

@QuLogic QuLogic moved this from Needs review to Waiting for author in First Time Contributors Mar 25, 2026
@buddy0452004
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @QuLogic! You're right the screenshots should show the full GUI window including the Tk/Qt frame and controls, not just the Matplotlib plot. I will retake the screenshots to show the complete embedding context.

@buddy0452004
Copy link
Copy Markdown
Contributor Author

buddy0452004 commented Mar 27, 2026

@QuLogic Retook all screenshots to show the full GUI window including title bar, toolbar, slider and controls. Also squashed all commits into one clean commit.

@buddy0452004 buddy0452004 force-pushed the add-thumbnail-embedding-tk branch from bf61460 to 88597e9 Compare March 27, 2026 10:10
@melissawm melissawm moved this from Waiting for author to Needs review in First Time Contributors Mar 27, 2026
@buddy0452004
Copy link
Copy Markdown
Contributor Author

Friendly ping @QuLogic @story645 happy to make any changes if needed.

@buddy0452004
Copy link
Copy Markdown
Contributor Author

Friendly ping @QuLogic @story645 all checks are passing and screenshots now show the full GUI window as requested. Happy to make any further changes if needed!

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

The thumbnails don't render because you have used a rST comment instead of a python comment. Please take more care and validate that a PR you propose actually solves the issue.

The images are larger than need be. Please recheck, but I think thumbnails should have a size of 320x224 px.

Also please run the images through a png minifier such as optipng or https://tinypng.com/

Comment on lines +6 to +7
.. sphinx_gallery_thumbnail_path = 'gallery/user_interfaces/images/canvasagg.png'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per https://sphinx-gallery.github.io/stable/configuration.html#providing-thumbnail this has to be a python comment, not an rST comment. So put at the beginning of the code section (l.29)

Also for all other examples.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Moved the thumbnail path to the code section as a Python comment (#) for all examples, resized images to 320x224px, and compressed them. Will push the updated commit shortly

@buddy0452004 buddy0452004 force-pushed the add-thumbnail-embedding-tk branch from 6cd1736 to db96ecd Compare April 18, 2026 07:16
Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply rescaling the images to 320x224 distorts them.

Either check whether other sizes work as well or pad with transparency appropriately.

@buddy0452004
Copy link
Copy Markdown
Contributor Author

Simply rescaling the images to 320x224 distorts them.

Either check whether other sizes work as well or pad with transparency appropriately.

Sorry about that! Will fix the images to preserve aspect ratio by padding with transparency instead of stretching.

@buddy0452004 buddy0452004 force-pushed the add-thumbnail-embedding-tk branch from 9302626 to 7662588 Compare April 18, 2026 09:16
@buddy0452004
Copy link
Copy Markdown
Contributor Author

Simply rescaling the images to 320x224 distorts them.

Either check whether other sizes work as well or pad with transparency appropriately.

Fixed the aspect ratio images are now padded with transparency to fit 320x224 without distortion

@timhoffm
Copy link
Copy Markdown
Member

Um no? E.g. ‎galleries/examples/user_interfaces/images/embedding_in_qt.png is obviously distorted

grafik

@buddy0452004 buddy0452004 force-pushed the add-thumbnail-embedding-tk branch from 7662588 to 6ef6ad9 Compare April 19, 2026 16:55
@buddy0452004
Copy link
Copy Markdown
Contributor Author

Um no? E.g. ‎galleries/examples/user_interfaces/images/embedding_in_qt.png is obviously distorted

grafik

Retook all screenshots in landscape orientation to avoid distortion. Images are 320x224 with transparent padding where needed

@timhoffm
Copy link
Copy Markdown
Member

@buddy0452004 buddy0452004 force-pushed the add-thumbnail-embedding-tk branch from 6ef6ad9 to a6460a3 Compare April 21, 2026 13:50
@buddy0452004
Copy link
Copy Markdown
Contributor Author

The images do not show up in the rendered docs: https://output.circle-artifacts.com/output/job/a27ab015-7022-49c3-bed8-3c0da41fca64/artifacts/0/doc/build/html/gallery/index.html#embedding-matplotlib-in-graphical-user-interfaces

Fixed the thumbnail paths to use _static/ and moved images there

@buddy0452004 buddy0452004 force-pushed the add-thumbnail-embedding-tk branch from a6460a3 to de662b8 Compare April 21, 2026 14:16
Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, works now.

As a final cleanup, please remove the unnecessary added empty lines.

DOC: Fix thumbnail comment syntax and resize images to 320x224

DOC: Fix image aspect ratio with transparent padding

DOC: Retake screenshots in landscape and fix aspect ratio

DOC: Move thumbnails to _static and fix thumbnail paths

DOC: Add SVG thumbnails to _static

DOC: Remove unnecessary blank lines
@buddy0452004 buddy0452004 force-pushed the add-thumbnail-embedding-tk branch from de662b8 to a0ec688 Compare April 22, 2026 07:50
@buddy0452004
Copy link
Copy Markdown
Contributor Author

Thanks, works now.

As a final cleanup, please remove the unnecessary added empty lines.

Removed the unnecessary blank lines.

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still blank lines.

Please note that the quality and your reactions are lacking, causing extra effort through additional review cycles. I'll now push the needed changes and squash merge, because it's not worth spending more time on this.

Comment thread galleries/examples/user_interfaces/canvasagg.py Outdated
Comment thread galleries/examples/user_interfaces/embedding_in_qt_sgskip.py Outdated
Comment thread galleries/examples/user_interfaces/embedding_webagg_sgskip.py Outdated
Co-authored-by: Tim Hoffmann <[email protected]>
@timhoffm timhoffm changed the title Add thumbnail for embedding_in_tk example Add thumbnail for embedding in user interfaces examples Apr 22, 2026
@timhoffm timhoffm merged commit e9637a6 into matplotlib:main Apr 22, 2026
17 of 19 checks passed
@github-project-automation github-project-automation Bot moved this from Needs review to Merged in First Time Contributors Apr 22, 2026
@buddy0452004
Copy link
Copy Markdown
Contributor Author

Thank you for the patience and for pushing the final fix. I'll make sure to test more carefully before submitting next time.

@QuLogic QuLogic added this to the v3.11.0 milestone Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

Add thumbnails for tutorials/gallery where missing

4 participants