How to get a list with the names of all Blender Panels?

I know I can get that names rudely this way:


import bpy


for name in dir(bpy.types):
    if getattr(bpy.types, name).mro()[1] == bpy.types.Panel:
        print(name)

But is there a better way to get these names?

for panel in bpy.types.Panel.__subclasses__():
    print(panel.__name__)

Wooow, perfect … and substantially faster. Your knowledge about python and Blender API is enviable @CoDEmanX. :slight_smile:

Now came a question regarding …
If I change a value of a Panel, how can I recover the default value?
For example, I can change a value like this:

>>> panel = bpy.types.VIEW3D_PT_tools_grease_pencil_draw
>>> print(panel.bl_category)
Grease Pencil


>>> panel.bl_category = 'My Category'
>>> print(panel.bl_category)
My Category

But when trying to get the default value, this error appears:

>>> default_category = bpy.types.VIEW3D_PT_tools_grease_pencil_draw().bl_category
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: bpy_struct.__new__(type): expected a single argument

How to get around this error?

Hm, store it in a global var? The type itself is one:

panel = bpy.types.VIEW3D_PT_tools_grease_pencil
panel._orginial_category = panel.bl_category

OK, works :slight_smile: