RickyBlender, maybe you can be a little more specific? The closest I have managed to obtain so far is :
import bpy
l = []
for curr in bpy.data.objects:
l.append( (curr.name, curr.name, curr.name) )
class ObjectPickerCombo(bpy.types.Operator):
bl_idname = "screen.stk_object_picker"
bl_label = ("SuperTuxKart object picker")
m_property_id = id
m_obj = ""
m_props = []
value = bpy.props.EnumProperty(attr="value", name="value", default=l[0][0],
items=l)
def invoke(self, context, event):
print("Outer invoke")
l = []
for curr in bpy.data.objects:
l.append( (curr.name, curr.name + " (updated)", curr.name + " (updated)") )
ObjectPickerCombo.value = bpy.props.EnumProperty(attr="value", name="value", default=l[0][0],
items=l)
context.region.tag_redraw()
upper = self
class ObjectPickerDialog(bpy.types.Operator):
bl_idname = "screen.stk_object_picker_dialog"
bl_label = ("SuperTuxKart select object")
m_upper = upper
the_list = l
def execute(self, context):
print("Exec inner")
context.region.tag_redraw()
context.window_manager.invoke_props_dialog(self)
context.region.tag_redraw()
return {'FINISHED'}
def draw(self, context):
self.m_props = []
layout = self.layout
for curr in self.the_list:
layout.prop_enum(self.m_upper, "value", curr[0])
self.l = l
#context.window_manager.invoke_props_dialog(self)
bpy.utils.register_class(ObjectPickerDialog)
context.region.tag_redraw()
bpy.ops.screen.stk_object_picker_dialog()
context.region.tag_redraw()
return {'RUNNING_MODAL'}
def execute(self, context):
context.region.tag_redraw()
print("Exec")
return {'FINISHED'}
bpy.utils.register_class(ObjectPickerCombo)
class HelloWorldPanel(bpy.types.Panel):
bl_idname = "OBJECT_PT_hello_world"
bl_label = "Hello World"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
self.layout.label(text="Hello World")
self.layout.operator("screen.stk_object_picker", text="", icon="TRIA_DOWN")
bpy.utils.register_class(HelloWorldPanel)
Apart from being surprisingly complicated, this little snippet also crashes blender. Maybe you can see what I’m doing wrong?