# Change Viewport Shading with Python Button

I've found the following script from this question

    area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
space = next(space for space in area.spaces if space.type == 'VIEW_3D')


I'm looking to use it in a Blend file that I have designed for colleagues of mine who are not proficient in 3d to load up and render a logo design that they have saved as a texture.

Currently I've got a panel with a bunch of colour options for them to adjust set in the Tool Shelf of the 3D window, there's also a nice big Render button.

The above code is now set into that script and means that when my colleagues open the file it automatically starts Cycles so that they can see the design, see below:

However I want it to default to Material, to avoid any problems with GPU crashes, and then have a couple of buttons in the panel to jump between the 2 options.

I'm guessing it's going to require some if statements but I've never done this in Python before, I'm a PHP programmer normally so understand the concept.

Any help would be gratefully appreciated.

• The scene looks like it could be handled just fine by EEVEE (Blender 2.8). Have you checked already? – John Dvorak Jan 9 '19 at 15:01
• It will work in EEVEE but for now I want to stick to the Official Build. – Tom Jelfs Jan 9 '19 at 15:10
• The beta build is as official as the stable release ;-) – John Dvorak Jan 9 '19 at 15:17
• Yes I know that, but you know what I mean. Plus this scripting didn't play nice when I just tried it in Beta. – Tom Jelfs Jan 9 '19 at 15:25