Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- class MyProperties(bpy.types.PropertyGroup):
- my_string : bpy.props.StringProperty(name= "Password", subtype= 'PASSWORD')
- class ADDONNAME_PT_main_panel(bpy.types.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
- row = layout.row()
- split = row.split(factor= 0.5)
- row.prop(mytool, "my_string")
- layout.operator("addonname.myop_operator")
- class ADDONNAME_OT_my_op(bpy.types.Operator):
- bl_label = "Confirm"
- bl_idname = "addonname.myop_operator"
- def execute(self, context):
- scene = context.scene
- mytool = scene.my_tool
- if mytool.my_string == "awesomepassword":
- bpy.ops.mesh.primitive_cube_add()
- 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 = bpy.props.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