fix for various python bugs and remove unused var.
[blender.git] / release / scripts / templates / operator_simple.py
index e241afd23b797e5162bdd23a7f313bb745da9a51..8348c7a95b13a17b0dd42210cc6d5de6e8e2e863 100644 (file)
@@ -1,15 +1,18 @@
 import bpy
 
+
 def main(context):
     for ob in context.scene.objects:
         print(ob)
 
+
 class SimpleOperator(bpy.types.Operator):
-    ''''''
+    '''Tooltip'''
     bl_idname = "object.simple_operator"
     bl_label = "Simple Object Operator"
 
-    def poll(self, context):
+    @classmethod
+    def poll(cls, context):
         return context.active_object != None
 
     def execute(self, context):
@@ -17,5 +20,16 @@ class SimpleOperator(bpy.types.Operator):
         return {'FINISHED'}
 
 
+def register():
+    bpy.utils.register_class(SimpleOperator)
+
+
+def unregister():
+    bpy.utils.unregister_class(SimpleOperator)
+
+
 if __name__ == "__main__":
+    register()
+
+    # test call
     bpy.ops.object.simple_operator()