fix for various python bugs and remove unused var.
[blender.git] / release / scripts / templates / operator_simple.py
index 985a628c2d01869d5c1166390a8357dd26c3053b..8348c7a95b13a17b0dd42210cc6d5de6e8e2e863 100644 (file)
@@ -1,26 +1,35 @@
 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):
         main(context)
         return {'FINISHED'}
 
+
 def register():
-    bpy.types.register(SimpleOperator)
+    bpy.utils.register_class(SimpleOperator)
+
 
 def unregister():
-    bpy.types.unregister(SimpleOperator)
+    bpy.utils.unregister_class(SimpleOperator)
+
 
 if __name__ == "__main__":
     register()
+
+    # test call
+    bpy.ops.object.simple_operator()