how to make "operator_menu_enum" keep the selected value displayed I created a drop-down menu, with a operator_menu_enum referring to an EnumProperty.

When I select an entry in this menu, it closes, and display the default text string, instead of displaying the selected entry's string.

How to keep the selected entry displayed in the menu's head after selection ?

Edit : Here is an example script of the way I make the menu :

import bpy

class STUFF_PANEL(bpy.types.Panel):
    bl_idname = "SCENE_PT_stuffSelect"
    bl_label = "Stuff selection"
    bl_space_type = "PROPERTIES"
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.operator_menu_enum("stuff_list.menu", 'stuffList', text="Stuff list")
        if bpy.props.selectedStuff:
            row = layout.row()
            row.label("Selected stuff :")
            row.label(str(bpy.props.selectedStuff[1]))


class STUFF_LIST_OT_Menu(bpy.types.Operator):
    bl_idname = "stuff_list.menu"
    bl_description = "select something here"
    bl_label = "Menu"

    def get_stuff(self, context):
        return bpy.props.config_stuff_list

    stuffList = bpy.props.EnumProperty(
        items = get_stuff, name = "Stuff", description = "The stuff list")

    def execute(self, context):
        bpy.props.selectedStuff = [
            n for i, n in enumerate(bpy.props.config_stuff_list)\
            if n[0] == self.stuffList][0]
        return{'FINISHED'}


def register():
    bpy.props.selectedStuff = False
    bpy.props.config_stuff_list = [
        ("1","stuff 1","0"),("2","stuff 2","0"),("3","stuff 3","0")]
    bpy.utils.register_module(__name__)


def unregister():
    del bpy.props.config_stuff_list
    del bpy.props.selectedStuff
    bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
    register()
This feature isn't supported by operator_menu_enum, the purpose of this is to be a submenu containing options. Not a persistent drop-down selection box, you may be better off to add an update callback to an enum property, then selecting an option can run some python code.

What you wan't can be done, but I think you're looking in the wrong place.

Simple answer:

You could replace the row.operator_menu_enum line with this.

    if bpy.props.selectedStuff:
        label = str(bpy.props.selectedStuff[1])
    else:
        label = "Stuff list"
    row.operator_menu_enum("stuff_list.menu", 'stuffList', text=label)


Longer answer:

it looks like this is not using the API correctly. You can't easily access operator properties from a panel (when the operator isn't running), you're better off to add a property-group to the scene that contains all your tool properties, then have the operators invoke function initialize from these settings (this is how most Blender operators do this).

Note:


Setting attributes in bpy.props is bad practice, just store this in the script. (as a class attribute for example)