Boss_OT_base_ui

This is a blender operator class.

You can create Operator by inheriting from this class.

Check the Following Code

  • CreateCubeOperator inherits from Boss_OT_base_ui

  • a method ui_elements is defined, its actually overridden from base class.

  • ui_elements method is used to create UIs

import bpy
from boss.ui_creator import *

def onClick(caller):
   bpy.ops.mesh.primitive_cube_add(size=2)
   caller.op.quit()


class CreateCubeOperator(Boss_OT_base_ui):
   """Create A Simple Cube"""
   bl_idname = "boss.create_cube"
   bl_label = "Create Cube"

   def ui_elements(self):
       op = self
       UICreator.button(
           op,
           rectData=RectData(0, 0, 100, 40),
           text='text',
           buttonData=onClick,
       )


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

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


if __name__ == "__main__":
   register()

# test call
# bpy.ops.boss.create_cube()

Notes:

  1. Every UI created (Panel/Button) contains a reference to operator, it’s in the variable op

  2. In future updates, there will be more base operators for other needs. I will try to add as many features as possible in this base class and avoid creating many base classes with minor differences.