Object.DrawType Menu

Hello there o/
I’m Raphael and this is my very first post, so it doubles as a short introduction.
There’s something that really annoyed me for a long time: having to reach to the properties panel to change my model draw type to wireframe, while having my reference (imported by ImageAsPlanes) in Textured mode.

After a serie of frustrated takes at binding it to a hotkey without sucess, i decided to create a little context menu. I used the Materials Utils addon as a base, and honestly i can’t give full suport to this as a new addon yet, but i couldn’t get it working as a standalone script eighter so that was the solution. A Quick and dirty one for stance.

But then i began to wonder if someone else ever feel the need for it and (as with me)
found out the hard way that there’s nothing out there.
And that motivated me to post it here.

It’s really simple, Control+Shift+Q gives the 3 Options (WIRE, SOLID AND TEXTURED)


bl_info = {
    "name": "Object Draw Type",
    "author": "RaphaelKox",
    "version": (0, 1),
    "blender": (2, 6, 3),
    "location": "VIEW3D > Ctrl Alt Q key",
    "description": "Menu to set Draw Type of Active Object",
    "warning": "",
    "wiki_url": ""
                "",
    "tracker_url": ""
                   "",
    "category": "3D View"}


import bpy
from bpy.props import*

def changedrawtype(ob, type):
    if type == 'WIRE':
        ob.draw_type = 'WIRE'
    elif type == 'SOLID':
        ob.draw_type = 'SOLID'
    elif type == 'TEX':
        ob.draw_type = 'TEXTURED'
    

# Operators
#----------------------------------------------

# Set Wireframe
#-----------------------------------------------
class VIEW3D_OT_setdrawwire(bpy.types.Operator):
    bl_idname = "view3d.setdrawwire"
    bl_label = "Set Object DrawType Wire"
    bl_options = {'REGISTER', 'UNDO'}
    
    @classmethod
    def poll(cls, context):
        return context.active_object != None
    
    def execute(self, context):
        objct = context.active_object
        changedrawtype(objct, 'WIRE')
        return {'FINISHED'}
    
# Set Solid
#-----------------------------------------------
class VIEW3D_OT_setdrawsolid(bpy.types.Operator):
    bl_idname = "view3d.setdrawsolid"
    bl_label = "Set Object DrawType Solid"
    bl_options = {'REGISTER', 'UNDO'}
    
    @classmethod
    def poll(cls, context):
        return context.active_object != None
    
    def execute(self, context):
        objct = context.active_object
        changedrawtype(objct, 'SOLID')
        return {'FINISHED'}

# Set Textured
#-----------------------------------------------
class VIEW3D_OT_setdrawtextured(bpy.types.Operator):
    bl_idname = "view3d.setdrawtextured"
    bl_label = "Set Object DrawType Textured"
    bl_options = {'REGISTER', 'UNDO'}
    
    @classmethod
    def poll(cls, context):
        return context.active_object != None
    
    def execute(self, context):
        objct = context.active_object
        changedrawtype(objct, 'TEX')
        return {'FINISHED'}


# Menu
#--------------------------------------------------
class VIEW3D_MT_drawtype(bpy.types.Menu):
    bl_label = "Set Object DrawType"
    
    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        
        layout.operator("view3d.setdrawwire", text='Wire', icon='WIRE')
        layout.operator("view3d.setdrawsolid", text='Solid', icon='SOLID')
        layout.operator("view3d.setdrawtextured", text='Textured', icon='POTATO')

                
def register():
    bpy.utils.register_module(__name__)
    
    kc = bpy.context.window_manager.keyconfigs.addon
    if kc:
        km = kc.keymaps.new(name="3D View", space_type="VIEW_3D")
        kmi = km.keymap_items.new('wm.call_menu', value='PRESS', type='Q', ctrl=True, alt=False, shift=True, oskey=False)
        kmi.properties.name = "VIEW3D_MT_drawtype"


def unregister():
    bpy.utils.unregister_module(__name__)
    
    kc = bpy.context.window_manager.keyconfigs.addon
    if kc:
        km = kc.keymaps["3D View"]
        for kmi in km.keymap_items:
            if kmi.idname == 'wm.call_menu':
                if kmi.properties.name == "VIEW3D_MT_master_material":
                    km.keymap_items.remove(kmi)
                    break
    

if __name__ == "__main__":
    register()

Nothing amazing, but i hope it help