Actually, it’s pretty easy to add a custom theme at runtime, and this doesn’t imply forking (or even require a PR). Just create a new
dict that mimics the keys of one of the existing values in
napari.utils.theme.palettes, and change any of values you’d like, and then add your new
# copy an existing theme for simplicity
my_theme = napari.utils.theme.palettes['dark'].copy()
# change what you want
'background': 'rgb(29, 53, 87)',
'foreground': 'rgb(69, 123, 157)'
# add your theme to the palettes
napari.utils.theme.palettes['my_theme'] = my_theme
viewer = napari.Viewer()
# use it!
viewer.theme = 'my_theme'
The one main caveat here, is that currently you must have the value for the
"folder" key in your theme dict be either “dark” or “light” (this will determine icon colors) … this is because the icons are pre-generated from SVG files at launch. To be able to adjust icon colors, we’ll need to expose more control, likely as a plugin. Adjustable themes was one of the early proposals for plugin ideas, but it hasn’t been done yet.
… but if you want to change things besides colors, then yes, you’ll need use the full
setStylesheet trick you mentioned above