Can Python switch Themes upon Scene change?

While I can’t yet write a script to do this, I am wondering if it’s possible to trigger a Theme change based on switching scenes? As this is a non animated change to UI is it something Python can do?

I am wondering if it’s possible to make a colour change in the Info bar background, (making scene change more obvious). I see that items in themes can’t be driven by scene changes, so I wondered about just having a bunch of themes allocated to scenes instead. The only change would be a different nominated colour bar per scene.

you are lucky: a scene change causes a frame change event, so you can use the app handler frame_change_pre or frame_change_post.

You can change the background color by:

bpy.context.user_preferences.themes[0] = (1,0,0)

Hmm ok that sounds promising.

Ooh, this is fun. I guess I have to create a list of scenes and allocate a colour to each…? Then wait for scene change. But how can I know when the frame change is due to a scene change instead of a regular animation playback?

you can store the name of the scene that was active last in bpy.types.WindowManager and compare that. Or complete ignore it, and just set the color again and again - as long as this doesn’t slow down Blender, it should be fine, and look fine to the user.