-
Notifications
You must be signed in to change notification settings - Fork 59
Update Theme contribution guidance #1002
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
Open
TimMonko
wants to merge
5
commits into
napari:main
Choose a base branch
from
TimMonko:npe2-themes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−31
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
daf4bef
fix migration guide syntax
TimMonko afeabfd
update viewer guide theme quip
TimMonko 387ea5d
simplify themes page and use theme sample example
TimMonko e3f0438
Apply suggestion from @brisvag
TimMonko 68305d4
Apply suggestions from code review
TimMonko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,43 +2,42 @@ | |
|
|
||
| # Creating and testing themes | ||
|
|
||
| A theme is a set of colors used throughout napari. See, for example, the | ||
| builtin themes in `napari/utils/theme.py`. To make a new theme, create a new | ||
| `dict` with the same keys as one of the existing themes, and | ||
| replace the values with your new colors. For example | ||
| A napari theme is a named collection of colors and style values used across the | ||
| viewer canvas, widgets, icons, and console. If you want to programmatically | ||
| prototype a theme, check out the {ref}`shpx_glr_gallery_new_theme.py` example. | ||
| However, the `npe2` theme contribution allows declaratively | ||
| defining themes and enables easy distribution to others. | ||
|
TimMonko marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```python | ||
| from napari.utils.theme import get_theme, register_theme | ||
| If you want other people to install and reuse your theme, prefer the plugin | ||
| workflow. The programmatic workflow is still useful for local experiments and | ||
| rapid iteration. | ||
|
Comment on lines
+11
to
+13
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might be worth an admonition and having things link to the section headers? |
||
|
|
||
| (preview-themes)= | ||
| ## Preview themes in a full napari UI | ||
|
|
||
| blue_theme = get_theme('dark') | ||
| blue_theme.update( | ||
| background='rgb(28, 31, 48)', | ||
| foreground='rgb(45, 52, 71)', | ||
| primary='rgb(80, 88, 108)', | ||
| current='rgb(184, 112, 0)', | ||
| ) | ||
| The most complete theme preview tool lives in the example gallery as | ||
| {ref}`sphx_glr_gallery_theme_sample.py`. It opens napari with a dock widget | ||
| that shows the theme color roles, common widget states, and a theme selector | ||
| that includes plugin-contributed themes after plugins are initialized. | ||
|
|
||
| register_theme('blue', blue_theme) | ||
| ``` | ||
| You can download the python script from the example page and drag'n'drop it onto napari to run it. | ||
|
|
||
| To test out the theme, use the | ||
| `qt_theme_sample.py` file from the command line as follows: | ||
| If you are working from a local checkout of `napari/napari`, you can run it | ||
| directly: | ||
|
|
||
| ```sh | ||
| python -m napari._qt.widgets.qt_theme_sample | ||
| python examples/theme_sample.py | ||
| ``` | ||
|
|
||
| *note*: you may specify a theme with one additional argument on the command line: | ||
|
|
||
| ```sh | ||
| python -m napari._qt.widgets.qt_theme_sample dark | ||
| ``` | ||
| ## Ship a theme in a plugin | ||
|
|
||
| (providing no arguments will show all themes in `theme.py`) | ||
| The supported way to distribute a theme is via a [plugin](plugins-index) | ||
| [theme contribution](contributions-themes). A theme contribution uses the plugin manifest | ||
| (`napari.yaml`) to declaratively define properties of a theme. | ||
|
|
||
| ## Sharing your theme via a plugin | ||
| After the plugin is installed, the contributed theme becomes available in | ||
| napari's appearance settings and can also be selected with `viewer.theme`. | ||
| For richer visual testing, use the [theme preview sample](preview-themes). | ||
|
|
||
| You can also share your theme with the community via a [plugin](plugins-index) | ||
| by adding a [theme contribution](contributions-themes). See the | ||
| [plugin](plugins-index) documentation for details on creating a plugin. | ||
| If you are contributing a builtin theme to napari itself rather than shipping a | ||
| plugin, see the core theme definitions in `napari/utils/theme.py`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.