Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- from bpy.types import Panel, Operator, PropertyGroup
- from bpy.props import FloatProperty, PointerProperty
- class MyProperties(PropertyGroup):
- my_float : bpy.props.FloatProperty(name= "Number", default= 0)
- class ADDONNAME_PT_main_panel(Panel):
- bl_label = "Main Panel"
- bl_idname = "ADDONNAME_PT_main_panel"
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'UI'
- bl_category = "New Tab"
- def draw(self, context):
- layout = self.layout
- scene = context.scene
- mytool = scene.my_tool
- layout.prop(mytool, "my_float")
- layout.operator("addonname.myop_operator")
- class ADDONNAME_OT_my_op(Operator):
- bl_label = "Button"
- bl_idname = "addonname.myop_operator"
- def execute(self, context):
- scene = context.scene
- mytool = scene.my_tool
- return {'FINISHED'}
- classes = [MyProperties, ADDONNAME_PT_main_panel, ADDONNAME_OT_my_op]
- def register():
- for cls in classes:
- bpy.utils.register_class(cls)
- bpy.types.Scene.my_tool = PointerProperty(type= MyProperties)
- def unregister():
- for cls in classes:
- bpy.utils.unregister_class(cls)
- del bpy.types.Scene.my_tool
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement