2.8 XRay command to Pie Menu

Hi, I’m trying to get the new XRay command into a Pie Menu.

this is the new command captured in the INFO window, but I don’t know how to translate that into a PieMenu:
bpy.data.screens[“Default”].shading.show_xray = True

I’m trying to recreate a PieMenu command I had in 2.7x, that TOGGLES ‘occlude geometry’. If you were in ObjectMode it would enter EditMode - and toggle occlude geo.
This is how that class looked:

# Define Class Limit to Visible
class ClassLimitToVisible(bpy.types.Operator):
    bl_idname = "class.limittovis"
    bl_label = "Class Limit to Visible"

    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode == "OBJECT":
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.ops.wm.context_toggle(data_path="space_data.use_occlude_geometry")
        elif bpy.context.object.mode == "EDIT":
            bpy.ops.wm.context_toggle(data_path="space_data.use_occlude_geometry")
        return {'FINISHED'}

Anyone know how I’d translate this to 2.8 ?

# Define Class Limit to Visible
class ClassLimitToVisible(bpy.types.Operator):
    bl_idname = "class.limittovis"
    bl_label = "Class Limit to Visible"

    def execute(self, context):
        layout = self.layout
        
        if bpy.context.object.mode == "OBJECT":
            bpy.ops.object.mode_set(mode="EDIT")
            bpy.ops.wm.context_toggle(data_path="space_data.shading.show_xray")
        elif bpy.context.object.mode == "EDIT":
            bpy.ops.wm.context_toggle(data_path="space_data.shading.show_xray")
        return {'FINISHED'}
1 Like

Thanks!
Really appreciate you taking the time to help out!