In Python is it possible to change the background color of a property ui?
The colors are controlled by C code, you can't set it to arbitrary colors with python.

However, you can change the background to alert color (=red) by setting the alert property on the layout block:



import bpy


class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout

        obj = context.object
        if obj is None: return

        col = layout.column()
        col.alert = True
        col.label("Alert state NOT supported:")

        box = col.box()
        box.label("Labels", icon="X")
        box.menu("VIEW3D_MT_object", text="Menus")
        box.prop(obj, "layers", text="Not all properties")

        col.separator()
        col.label("Supported:")
        box = col.box()
        box.operator("mesh.primitive_cube_add", text="Operators (Buttons)")
        box.prop(obj, "name", text="Many properties")
        box.prop(obj, "location", index=1, text="Vector props: only single")
        box.label("also with emboss=False, but...")
        box.prop(obj, "name", text="read-only?!", emboss=False)
        box.label("template_list() sort of (needs materials):")
        box.template_list("UI_UL_list", "foobar", obj.data, "materials", obj, "active_material_index")

def register():
    bpy.utils.register_class(HelloWorldPanel)


def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)


if __name__ == "__main__":
    register()


Run the above code in Text Editor and check out the Object tab.