# How to display EnumProperty control like radio buttons, while keeping the selection exclusive?

I have an EnumProperty set up on the Scene in the register function:

def register():
bpy.types.Scene.my_enum = bpy.props.EnumProperty(
name = "My enum",
description = "My enum description",
items = [
("FIRST" , "First one" , "Description..."),
("SECNOD", "Second one", "Some other description")
]
)


Now, elsewhere in the code I have a Panel, which is to display the 'enum' for selection:

class SomePanel(bpy.types.Panel):
bl_idname      = "some_panel"
bl_label       = "A panel"
bl_space_type  = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context     = "render"

def draw(self, context):
layout = self.layout
scene = context.scene
layout.prop(scene, "my_enum")


So far so good, the control draws correctly, but not the way I want:

Thing is - I wanted a different appearance - I didn't want a dropdown field, instead I want a radio-button like field, as the one found for example here:

... where I can choose one of the options regarding the color mode (BW , RGB or RGBA).

I've found that I can put the "ENUM_FLAG" in the options field of the EnumProperty definition:

def register():
bpy.types.Scene.my_enum = bpy.props.EnumProperty(
name = "My enum",
description = "My enum description",
items = [
("FIRST" , "First one" , "Description..."),
("SECNOD", "Second one", "Some other description")
],
options = {"ENUM_FLAG"}
)


This too worked fine, the result I got now is this:

But now I can activate both buttons at once using Shift, and that's what I want to avoid:

So How can make the selection exclusive? How to force Blender to switch from one option to the other (or in other words: How to disable the Shift functionality)?

• I struggle with the title of this question, it seems to me it should include " giving visibility to all items at once" (like a radio button array). – zeffii Dec 25 '15 at 13:06
• @zeffii Perhaps it could sound this way, but I've considered putting all the context in the title to be an overkill. – luke1985 Dec 25 '15 at 13:39
• @zeffii Is it better now? – luke1985 Dec 25 '15 at 13:43
• Remove the options = {'ENUM_FLAG'} to remove multi-select. You can then set a default.,, eg default='FIRST', – batFINGER Dec 25 '15 at 15:55
• @luke1985 I don't know if there's a 'better', only time and upvotes will tell. I agree context-overkill could happen, but if you don't mention options={'ENUM_FLAG'} then non-exclusivity isn't even in the realm of possibilities for the enum. hence my thoughts about the title. – zeffii Dec 25 '15 at 20:50

Booleans have toggle=True, and Enums have expand=True
layout.prop(scene, "my_enum", expand=True)

The most extensive UI cookbook is still this one though the layout docs are definitely useful after you've struggled a little. Other than those two sources I find it best to read through the draw functions of the add-ons supplied with Blender (you probably did this already.. if not, do)