Advertisement
Guest User

Untitled

a guest
Oct 5th, 2020
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. import bpy
  2. from bpy.types import Panel, Operator, PropertyGroup
  3. from bpy.props import FloatProperty, PointerProperty
  4.  
  5.  
  6. class MyProperties(PropertyGroup):
  7.    
  8.     my_float : bpy.props.FloatProperty(name= "Number", default= 0)
  9.    
  10.    
  11.  
  12.  
  13. class ADDONNAME_PT_main_panel(Panel):
  14.     bl_label = "Main Panel"
  15.     bl_idname = "ADDONNAME_PT_main_panel"
  16.     bl_space_type = 'VIEW_3D'
  17.     bl_region_type = 'UI'
  18.     bl_category = "New Tab"
  19.  
  20.     def draw(self, context):
  21.         layout = self.layout
  22.         scene = context.scene
  23.         mytool = scene.my_tool
  24.        
  25.         layout.prop(mytool, "my_float")
  26.         layout.operator("addonname.myop_operator")
  27.  
  28.  
  29.  
  30.  
  31. class ADDONNAME_OT_my_op(Operator):
  32.     bl_label = "Button"
  33.     bl_idname = "addonname.myop_operator"
  34.        
  35.     def execute(self, context):
  36.         scene = context.scene
  37.         mytool = scene.my_tool
  38.        
  39.        
  40.         return {'FINISHED'}
  41.    
  42.  
  43.  
  44.  
  45. classes = [MyProperties, ADDONNAME_PT_main_panel, ADDONNAME_OT_my_op]
  46.  
  47.  
  48.  
  49. def register():
  50.     for cls in classes:
  51.         bpy.utils.register_class(cls)
  52.        
  53.         bpy.types.Scene.my_tool = PointerProperty(type= MyProperties)
  54.  
  55. def unregister():
  56.     for cls in classes:
  57.         bpy.utils.unregister_class(cls)
  58.         del bpy.types.Scene.my_tool
  59.  
  60.  
  61.  
  62. if __name__ == "__main__":
  63.     register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement