Take the 2-minute tour ×
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It's 100% free, no registration required.

I am trying to write a script to set Interface colours for individual scenes. When I switch scenes in the Info bar drop down menu I want to change the Info Bar background colour. This gives better feedback for scene swapping/tracking. So far I've got bpy.context.user_preferences.themes[0].info.space.header = (1,0,0)

  • I guess I need to create an open list of scenes that I can append later.

  • Then allocate the spectrum of colours to it?

  • Not sure I can create a UI to allocate colours to scenes, so I'll have to bump the values in increments instead.

But first I'm stuck on calling the colour change (I considered iterating a bunch of themes and switching them as needed). At the BA forum it was suggested that the scene change is a frame change event but I'm not sure how to separate that from any other frame changes...

Hopefully if I can set up colours for the info bar I could tie them to node scene inputs.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

Cool idea, I wrote this addon for me just now and I triggered the Header draw event. You can copy it from below or from here: scene_colored_header.py

EDIT: Updated to the newer Version. Don't use the old version, it generates a continuous redraw of the Header, wich I don' noticed. leads to cpu inceasement

the updated Version:

    #scene_colored_header.py
bl_info = {
           "name": "Colored Header for each scene",
           "author": "Leon95, Idea: 3pointedit",
           "version": (1, 1),
           "blender": (2, 68, 0),
           "location": "Properties > Scene Tab > Scene Panel > Display Color",
           "description": "Define a Header Color for every scene and display it in the Header",
           "category": "Scene"
           }

import bpy

def_color = bpy.props.FloatVectorProperty(size = 3,min = 0.0,max = 1.0,
    default=bpy.context.user_preferences.themes[0].info.space.header.copy())
def_color = bpy.context.user_preferences.themes[0].info.space.header.copy()



def ui_properties_costum_header_color(self, context):
    row = self.layout.row()
    row.prop(context.scene, "headerColor")

def ui_info_header_refresh(self, context):
    #assign the property to the header theme every time it is redrawn
    l_co=context.window_manager.lastHeaderColor
    ch = context.user_preferences.themes[0].info.space.header
    cs = context.scene.headerColor
    #check, if reassignment is needed, since  assigning a color leads to redraw
    #(which the causes some kind of stack overflow)
    if not (round(l_co[0],3) == round(cs[0],3) and round(l_co[1],3) == round(cs[1],3) and round(l_co[2],3) == round(cs[2],3)):
        bpy.context.user_preferences.themes[0].info.space.header = bpy.context.scene.headerColor
    context.window_manager.lastHeaderColor=[cs[0],cs[1],cs[2]]


def register():
    co = bpy.context.user_preferences.themes[0].info.space.header.copy()
    bpy.types.WindowManager.lastHeaderColor=bpy.props.FloatVectorProperty(size = 3,min = 0.0,max = 1.0)
    bpy.types.Scene.headerColor = bpy.props.FloatVectorProperty(
                                     name = "Display Color",
                                     subtype = "COLOR",
                                     size = 3,
                                     min = 0.0,
                                     max = 1.0,
                                     update = ui_info_header_refresh,
                                     default = co)

    bpy.types.SCENE_PT_scene.append(ui_properties_costum_header_color)
    bpy.types.INFO_HT_header.append(ui_info_header_refresh)
    #bpy.app.handlers.frame_change_post.append(ui_info_header_refresh)

    #reassigment forces redraw
    bpy.context.user_preferences.themes[0].info.space.header = bpy.context.user_preferences.themes[0].info.space.header

def unregister():
    bpy.types.SCENE_PT_scene.remove(ui_properties_costum_header_color)
    bpy.types.INFO_HT_header.remove(ui_info_header_refresh)
    #bpy.app.handlers.frame_change_post.remove(ui_info_header_refresh)
    bpy.context.user_preferences.themes[0].info.space.header = [def_color[0],def_color[1],def_color[2]]
    bpy.context.window_manager.lastHeaderColor=[0,0,0]
    del bpy.types.WindowManager.lastHeaderColor


if __name__ == "__main__":
    register()
share|improve this answer
    
The coolest thing is that you can animate the header color :) –  Leon95 Aug 30 '14 at 20:57
1  
+1 This is pretty sweet. A cool idea from op indeed, registered and currently using it. Only critique is by default the color changes are rather subtle. –  iKlsR Aug 30 '14 at 21:04
    
That is AWESOME, thanks sooo much! At least now I have a script to learn from, win win. –  3pointedit Aug 31 '14 at 7:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.