# How do I get a popup UV Image Editor and force it to show the Active Paint Slot?

This is a question that is an aside from my previous question of How to get name of image corresponding to active paint slot?

And in that question, I was looking to ultimately arrive at an Image Editor as a popup to use quickly while painting in 3d view that would immediately show the active paint slot to take advantage of the way that the Editor only shows one image at a time.

My own code from the previous post only gets the active texture to coincide with the current active paint slot, but by myself I did not get the popup editor to show it.

Blender does not support creating a new window officially. However, there is an obscure workaround, you can open up a new user preferences window and change its type to IMAGE_EDITOR.

In order to display the active paint slot in that window, just get the active image slot reference and then assign it to SpaceImageEditor.image. Following code is a simple operator, you can either install it like an Add-on or paste and run it in blenders text editor per session.

bl_info = {
"name": "Display active Slot",
"description": "",
"author": "brockmann",
"version": (0, 0, 1),
"blender": (2, 70, 0),
"location": "Texture Paint > Tools Panel > Slots",
"category": "Paint"
}

import bpy

class DisplayActivePaintSlot(bpy.types.Operator):
'''Display selected paint slot in new window'''
bl_label = "Display active Slot"
bl_idname = "paint.display_active_slot"
bl_options = {'REGISTER', 'UNDO'}

@classmethod
def poll(self, context):
return context.object.active_material.texture_paint_images

def execute(self, context):
if context.object.active_material.texture_paint_images:
# Get the Image
mat = bpy.context.object.active_material
image = mat.texture_paint_images[mat.paint_active_slot]
# Call user prefs window
bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
# Change area type
area = context.window_manager.windows[-1].screen.areas[0]
area.type = 'IMAGE_EDITOR'
# Assign the Image
context.area.spaces.active.image = image
else:
self.report({'INFO'}, "No active Slot")
return {'FINISHED'}

def draw_display_slot_operator(self, context):
if context.object.active_material.texture_paint_images:
layout = self.layout
row = layout.row(align=True)
row.operator(DisplayActivePaintSlot.bl_idname, icon='IMAGE_COL')

def register():
bpy.utils.register_class(DisplayActivePaintSlot)
bpy.types.VIEW3D_PT_slots_projectpaint.prepend(draw_display_slot_operator)

def unregister():
bpy.utils.unregister_class(DisplayActivePaintSlot)
bpy.types.VIEW3D_PT_slots_projectpaint.remove(draw_display_slot_operator)

if __name__ == "__main__":
register()

# test call
#bpy.ops.paint.display_active_slot()

• Pulled this into my fork of Spirou4D's work on Texture Paint Plus, accessed with Shift-Alt-W github.com/artistCDMJ/texture_paint_plus/archive/master.zip – Craig D Jones Nov 10 '17 at 21:17
• Great @CraigDJones! But I think a link to this question/answer within the code would even make it more awesome (regarding to the community) ;D – brockmann Nov 11 '17 at 13:35
• Oh, man, I think I had that and then when I messed up the copy/paste I forgot to bring it. I will fix asap :D – Craig D Jones Nov 11 '17 at 18:11