Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So most code exmaples I find are using the option to list all shading options

pie.prop(context.space_data, "viewport_shade", expand=True)

But I would like to only show 3 and have the feeling that I have to create a new class operator to execute the code like:

bpy.context.space_data.viewport_shade = 'SOLID'

Am right with that assumption?

share|improve this question
up vote 3 down vote accepted

nope, to display a subset of an enum you can use wm.context_set_enum

        f = pie.operator("wm.context_set_enum", icon='SOLID', text='Solid')
        f.value = 'SOLID'

        f = pie.operator("wm.context_set_enum", icon='WIRE', text='Wires')
        f.value = 'WIREFRAME'

enter image description here

You might use a loop to reuse some code:

        modes = [
            ["SOLID", "SOLID", "Solid"],
            ["WIRE", "WIREFRAME", "Wires"],
            ["BBOX", "BOUNDBOX", "Bounds"]

        for ICON, VALUE, TEXT in modes:
            f = pie.operator("wm.context_set_enum", icon=ICON, text=TEXT)
            f.value = VALUE
share|improve this answer
Grrrr Just text is what you can use for the type - I would not have guessed that. – Claas Kuhnen Jan 9 at 23:02
Do you have a paypal account? – Claas Kuhnen Jan 9 at 23:06
oh wow - RENDERED does not have an icon you can select?!?! – Claas Kuhnen Jan 9 at 23:11
Yeah that's what I imagined and I use that icon as well already. Are you in Russia? Any other service? You help me so much. – Claas Kuhnen Jan 9 at 23:51
LOL - the icon the RENDERED mode uses is called "SMOOTH" – Claas Kuhnen Jan 9 at 23:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.