diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-18 19:47:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-18 19:47:26 +0300 |
commit | eedc3c09d112e85f346897875c851d2793da465c (patch) | |
tree | 33ad85cc1c6c400277627359e499eb9f6de7a2a0 /release/scripts/modules | |
parent | 13f28b6fa4dfe933231213d0a0920bf9fbd2e205 (diff) |
append/prepend class methods for the header and panels (previously only worked for menus)
Example of adding a button to the view header;
def draw_custom(self, context): self.layout.operator("some.operator")
bpy.types.VIEW3D_HT_header.append(draw_custom)
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 731757668bd..a1278f4f7cd 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -436,11 +436,11 @@ class Macro(StructRNA, metaclass=OrderedMeta): return ops.macro_define(self, opname) -class Menu(StructRNA): +class _GenericUI: __slots__ = () @classmethod - def _dyn_menu_initialize(cls): + def _dyn_ui_initialize(cls): draw_funcs = getattr(cls.draw, "_draw_funcs", None) if draw_funcs is None: @@ -457,14 +457,26 @@ class Menu(StructRNA): @classmethod def append(cls, draw_func): """Prepend an draw function to this menu, takes the same arguments as the menus draw function.""" - draw_funcs = cls._dyn_menu_initialize() + draw_funcs = cls._dyn_ui_initialize() draw_funcs.append(draw_func) @classmethod def prepend(cls, draw_func): """Prepend a draw function to this menu, takes the same arguments as the menus draw function.""" - draw_funcs = cls._dyn_menu_initialize() - draw_funcs.insert(0, draw_func) + draw_funcs = cls._dyn_ui_initialize() + draw_funcs.insert(0, draw_func) + + +class Panel(StructRNA, _GenericUI): + __slots__ = () + + +class Header(StructRNA, _GenericUI): + __slots__ = () + + +class Menu(StructRNA, _GenericUI): + __slots__ = () def path_menu(self, searchpaths, operator): layout = self.layout |