Advertisement
Guest User

Untitled

a guest
Aug 31st, 2020
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. import bpy
  2.  
  3.  
  4.  
  5.  
  6.  
  7. class MyProperties(bpy.types.PropertyGroup):
  8.    
  9.     my_string : bpy.props.StringProperty(name= "Password", subtype= 'PASSWORD')
  10.    
  11.  
  12.  
  13. class ADDONNAME_PT_main_panel(bpy.types.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.         row = layout.row()
  26.         split = row.split(factor= 0.5)
  27.        
  28.         row.prop(mytool, "my_string")
  29.        
  30.        
  31.  
  32.         layout.operator("addonname.myop_operator")
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. class ADDONNAME_OT_my_op(bpy.types.Operator):
  40.     bl_label = "Confirm"
  41.     bl_idname = "addonname.myop_operator"
  42.    
  43.    
  44.    
  45.     def execute(self, context):
  46.         scene = context.scene
  47.         mytool = scene.my_tool
  48.        
  49.         if mytool.my_string == "awesomepassword":
  50.             bpy.ops.mesh.primitive_cube_add()
  51.        
  52.            
  53.        
  54.        
  55.         return {'FINISHED'}
  56.    
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. classes = [MyProperties, ADDONNAME_PT_main_panel, ADDONNAME_OT_my_op]
  67.  
  68.  
  69.  
  70. def register():
  71.     for cls in classes:
  72.         bpy.utils.register_class(cls)
  73.        
  74.         bpy.types.Scene.my_tool = bpy.props.PointerProperty(type= MyProperties)
  75.  
  76. def unregister():
  77.     for cls in classes:
  78.         bpy.utils.unregister_class(cls)
  79.         del bpy.types.Scene.my_tool
  80.  
  81.  
  82.  
  83. if __name__ == "__main__":
  84.     register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement