I want to have two user preference windows so that I can quickly search for short cuts In one of them, and change themes or other settings in another one.

The problem is, all user preference panels share same states, if you change the active tab in one of them, any other same panels will change accordingly, which is unnecessary.

Any way to avoid this?

Essentially the goal is to make SpaceUserPref behave like SpaceText. You can have multiple text editors in the blender, while every instance has different list of texts.


1 Answer 1


keyword : active_section

Replicate the following sRNA fragment from makesrna/rna_userdef.c to rna_space.c :

    prop = RNA_def_property(srna, "active_section", PROP_ENUM, PROP_NONE);
    RNA_def_property_enum_sdna(prop, NULL, "userpref");
    RNA_def_property_enum_items(prop, user_pref_sections);
    RNA_def_property_ui_text(prop, "Active Section",
                             "Active section of the user preferences shown in the user interface");
    //RNA_def_property_update(prop, 0, "rna_userdef_update");

Then reverse transcript it into makesdna/DNA_Space_types.h:

/* User Preferences View */
typedef struct SpaceUserPref {
    short userpref; //new field
    short padpad;
} SpaceUserPref;

as field short userpref. Refer to the original UserDef structure.

By above two steps, we have replicated active_section property for the python type SpaceUserPreferences.

On the python side, by using this property instead of UserPreferences.active_section, the beheaviour of tab selection is now independent for each instances :


class USERPREF_PT_tabs(Panel):
    def draw(self, context):
        st = context.space_data
        if not hasattr(st, 'active_section'):
            st = context.user_preferences

        self.layout.row().prop(st, "active_section", expand=True)

def getContextualSection(context):
    st = context.space_data
    if not hasattr(st, 'active_section'):
        st = context.user_preferences
    return st.active_section

# edit poll method for every tab:
    def poll(cls, context):
        userpref = context.user_preferences
        return (getContextualSection(context) == 'INTERFACE')



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .