2
$\begingroup$

I want to change the category value of a panel. And I can get all bpy_class of a module like this:

import bpy_types
typemap_list = bpy_types.TypeMap.get(__name__, ())

for cls_weakref in typemap_list:
    cls = cls_weakref()
    if cls.bl_label == 'My Panel'
        cls.bl_category = 'New category name' # changed here
        break

But is it possible to get the right class without needing the loop?

$\endgroup$
4
$\begingroup$

You can get the panel in a single operation but not by label, since panels labels aren't necessarily unique, you should use the panel name.

eg:

cls = getattr(bpy.types, "VIEW3D_PT_view3d_display")

Note that bpy_types.TypeMap is part of Blenders internal logic which you're not meant to touch! :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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