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

Theme detection and update improvements#237

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
dstansby merged 8 commits intomatplotlib:mainfromChris-N-K:theme_detection_update
Jan 13, 2024

Conversation

Chris-N-K
Copy link
Contributor

@Chris-N-KChris-N-K commentedNov 30, 2023
edited
Loading

Hi,
as mentioned in the issue#236 I did a first draft of a possible implementation of dynamic styling based on thenapari viewer theme.

This rework completely omits the concept of static style sheets for the differentnapari theme and instead translates the current viewer theme into amatplotlib compatible style dictionary.

This happens upon widget initiation and the style dictionary is stored in the attribute:napari_theme_style_sheet.
The style dictionary can be directly used for amotplotlib.style.contect.
Additionally, I fixed the viewer theme callback and the style change upon theme change works now properly.

I encountered some strange during the rework, if I set thefacecolor of the figure or axes to something other than transparent (none) the color will stay. Seems like thefacecolors are not updated by redraws. I'm feel this is amatplotlib bug, but I could be wrong, maybe I just used the wrong functions for redrawing the figure and axis faces.
EDIT:
I can reproduce this behaviour with purematplotlib, if I explicitly set the facecolor and redraw it changes, but if I use a style context it stays the same.

If you find the implementation suitable you or I would need to give the test an update as well.

samcunliffe reacted with heart emoji
@dstansby
Copy link
Member

pre-commit.ci autofix

pre-commit-ci[bot] reacted with rocket emoji

@dstansby
Copy link
Member

dstansby commentedJan 7, 2024
edited
Loading

I really like this approach! Not having to deal with custom matplotlib style sheet paths makes life a lot simpler for us, and also gives the user only one place to customise the theme instead of having to do it for both napari and napari-matplotlib. I need to do some manual testing, but in the meantime would you be happy chaging either the code or tests to make the tests pass? If you're confused by the image tests (they are confusing!) just let me know and I can take a look at updating them.

I automatically fixed formatting issues, so there's now an extra commit on your branch. If you want to do taht yourself locally you can install and run pre-commit:https://pre-commit.com/

@dstansbydstansby added the New featureNew feature or request labelJan 7, 2024
@dstansbydstansby added this to the2.0 milestoneJan 7, 2024
@Chris-N-K
Copy link
ContributorAuthor

Hi, I'm happy you like my suggestions. I can take a look at the tests but I'm rather short on time at the moment so this could take some time.
If you are fine with taking a look at the image tests, I would go through the rest.

@dstansby
Copy link
Member

I've updated the image tests, and cleaned out the old styling code that isn't needed any more. I still need to debug some of the new images, as the text colour doesn't look right. Manual testing indicates this is looking good otherwise though 👍

Comment on lines -57 to -59
# callback to update when napari theme changed
# TODO: this isn't working completely (see issue #140)
# most of our styling respects the theme change but not all
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixes#140 ?

Copy link
ContributorAuthor

@Chris-N-KChris-N-KJan 12, 2024
edited
Loading

Choose a reason for hiding this comment

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

Yes it fixes the axelabel text colour issue, but is kind of a work around for the background issue.
All the text on the canvas (except in he legend) is now linked to the napari text colour which should always be high contrast to the background colour.
The background is transparent, which is not optimal in all cases, but for what ever reason I was not able to implement it in a way that the background is updated correctly.
I guess there might be an underlying bug not directly connected to napari-matplotlib but either napari or and this is my guess the way matplotlib updates the canvas.

@Chris-N-K
Copy link
ContributorAuthor

Looks like all the tests work now. Is there still something I should check?

@dstansby
Copy link
Member

dstansby commentedJan 13, 2024
edited
Loading

pre-commit.ci autofix

pre-commit-ci[bot] reacted with rocket emoji

@dstansby
Copy link
Member

Nope, I think this all looks good now 👍 . I'll wait for the tests to pass again then merge. Will try and get this in a new release in the next few weeks or so, thanks a lot for the PR!

Chris-N-K reacted with heart emoji

@dstansbydstansby merged commitc481207 intomatplotlib:mainJan 13, 2024
@Chris-N-KChris-N-K deleted the theme_detection_update branchJanuary 14, 2024 21:33
@Chris-N-K
Copy link
ContributorAuthor

Happy I could help ^^

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

@samcunliffesamcunliffesamcunliffe left review comments

@dstansbydstansbydstansby left review comments

Assignees
No one assigned
Labels
New featureNew feature or request
Projects
None yet
Milestone
2.0
Development

Successfully merging this pull request may close these issues.

3 participants
@Chris-N-K@dstansby@samcunliffe

[8]ページ先頭

©2009-2025 Movatter.jp