Hello
Some one can help me with information about this topic??
I look at api and I didn’t see anything
May be do you have some example that allow me understand?
May be something like this http://m.imgur.com/WRD0prj
Thanks
Diego
Hello
Some one can help me with information about this topic??
I look at api and I didn’t see anything
May be do you have some example that allow me understand?
May be something like this http://m.imgur.com/WRD0prj
Thanks
Diego
Should probably be done in C, not Python. I doubt there are any tutorials, you’ll have to check on existing code. In both cases, it would be a modal operator.
In that gif image I see that the user calls the built in menu (that with space bar) where all operators are listed automatically.
This is the “hardcore” way to invoke operators as long as you are within a proper context (e.g. other operators exist in bone edit mode and other operators exist in mesh edit mode).
An alternate way to do this is simply to use Blender’s functionality to make menus or operators popup right in front of you rather than placing them in menus.
Operators need:
context.window_manager.invoke_props_dialog(...)
Menus need:
bpy.ops.wm.call_menu(...)
The main part of interest is the operator, the other two menus are just decorational.
import bpy
class QuestionSelectYes(bpy.types.Menu):
bl_label = "Question For Selection"
bl_idname = "question_select_yes"
def draw(self, context):
layout = self.layout
layout.label("You selected it...")
class QuestionSelectNo(bpy.types.Menu):
bl_label = "Question For Selection"
bl_idname = "question_select_no"
def draw(self, context):
layout = self.layout
layout.label("You didn't select it...")
class Question(bpy.types.Operator):
bl_idname = "tools.question"
bl_label = "Question For Selection"
answer = bpy.props.BoolProperty(name="Yes I want to select it.")
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def draw(self, context):
layout = self.layout
layout.label("Are you really sure you want to select it?")
layout.prop(self, "answer")
pass
def execute(self, context):
if self.answer:
bpy.ops.wm.call_menu(name=QuestionSelectYes.bl_idname)
else:
bpy.ops.wm.call_menu(name=QuestionSelectNo.bl_idname)
return {'FINISHED'}
bpy.utils.register_class(Question)
bpy.utils.register_class(QuestionSelectYes)
bpy.utils.register_class(QuestionSelectNo)
If anyone knows more about this I would be interested to know as well.