[Bf-blender-cvs] [c879456] pie-menus: Correct example

Campbell Barton noreply at git.blender.org
Thu Aug 7 15:48:54 CEST 2014


Commit: c8794563f10202900d1d7d955e327d1da97c3cbe
Author: Campbell Barton
Date:   Thu Aug 7 23:48:40 2014 +1000
Branches: pie-menus
https://developer.blender.org/rBc8794563f10202900d1d7d955e327d1da97c3cbe

Correct example

===================================================================

M	release/scripts/templates_py/ui_pie_menu.py

===================================================================

diff --git a/release/scripts/templates_py/ui_pie_menu.py b/release/scripts/templates_py/ui_pie_menu.py
index a3461b9..35044fb 100644
--- a/release/scripts/templates_py/ui_pie_menu.py
+++ b/release/scripts/templates_py/ui_pie_menu.py
@@ -3,9 +3,14 @@ from bpy.props import *
 from bpy.types import Operator
 from bpy.types import Menu
 
-#expand an operator's macro in a pie menu
+# expand an operator's macro in a pie menu
 
-myitems = (('0','Hey Lady!', ''),('1','Spaaaaaaaceeeee!',''),('2','Wanna be awesome in space?',''), ('3','The fact sphere is always useful',''))
+my_items = (
+    ('ONE', "Im First!", ""),
+    ('SPACE', "Space!", ""),
+    ('AWESOME', "Wanna be awesome in space?", ""),
+    ('SPHERE', "The fact sphere is always useful", ""),
+    )
 
 
 class TestPieOperator(bpy.types.Operator):
@@ -13,14 +18,18 @@ class TestPieOperator(bpy.types.Operator):
     bl_idname = "wm.test_pie_operator"
     bl_label = "Simple Pie Sticky Operator"
 
-    test_type = EnumProperty(name='test_type', items = myitems, default='3')
+    test_type = EnumProperty(
+            name='test_type',
+            items=my_items,
+            default='AWESOME',
+            )
 
     @classmethod
     def poll(cls, context):
         return True
 
     def execute(self, context):
-        print("The sphere core says: " + myitems[int(self.test_type)][1])
+        print("The sphere core says:", self.test_type)
         return {'FINISHED'}
 
 
@@ -37,7 +46,7 @@ class VIEW3D_PIE_template(Menu):
 def register():
     bpy.utils.register_class(TestPieOperator)
     bpy.utils.register_class(VIEW3D_PIE_template)
- 
+
 
 def unregister():
     bpy.utils.unregister_class(TestPieOperator)
@@ -46,7 +55,6 @@ def unregister():
 
 if __name__ == "__main__":
     register()
-    
-    bpy.ops.wm.call_pie_menu(name="VIEW3D_PIE_template")
 
+    bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_template")




More information about the Bf-blender-cvs mailing list