How to change the default background color of slicerCAT

I know the python script can help change the background color.

Now I wan to change the color in the source code.

Which file should I edit?

Is there a reason why you can’t continue to use a python script to change the background color of the 3D view?

We generally include a python scripted module (called ‘Home’ or similar) that can be used to apply python scripted changes to the application appearance (see this blog: https://www.kitware.com/slicercat-and-python-creating-custom-slicer-applications-with-qt-stylesheets/)

If I click the ‘close scene’,I still hope the color is the sytle I preset.

If I write the script in the home.py, it just works for the first start of App.

@Sam_Horvath should appearance customization of the Slice Views (3D View Background color, Orientation Marker, Ruler, etc), only be reset with the “Reset to default” action of the appearance menu? Currently all of these are reset with a scene clear.

image

I see! Some properties of the views are stored as nodes, and so are cleared when the scene is closed.

You can

  • detect the scene close and re-apply the changes or
  • apply the changes both to the existing node and to the default node that will be used to create new ones on the scene close

Here is what you would add to your existing code for option 2 (option 1 is a little verbose, so lets see if this one works for you):

defaultViewNode = slicer.vtkMRMLViewNode()
defaultViewNode.SetBackgroundColor(1,0,0)
slicer.mrmlScene.AddDefaultNode(defaultViewNode)

@jamesobutler Since these settings are stored in nodes, they are dumped with the scene clear. It will be tricky to rework this behavior

2 Likes