0

How to add Image Browser to custom panel using Python or addon Serpens 3? Look like World Browser in this sample.

enter image description here

M. Gordon
  • 29
  • 5

1 Answers1

1

1) Property in the side panel

To create a property in the viewports side panel (N-panel) aramature selection

use the script from this question (How to access pose bones via python in this condition?) and replace select_rig with select_image and these lines

    # select_rig should point to an Object of type 'ARMATURE'
    bpy.types.Scene.select_rig = bpy.props.PointerProperty(name='Select Rig',
        type=bpy.types.Object, poll=scene_mychosenobject_poll)

with this line

    bpy.types.Scene.select_image = bpy.props.PointerProperty(name='Image',type=bpy.types.Image)

2) Property in the World Properties window

import bpy

class SelectImagePanel(bpy.types.Panel): """Creates a Panel in the World properties window""" bl_label = "World Image Panel" bl_idname = "OBJECT_PT_select_image" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "world"

def draw(self, context):
    layout = self.layout

    obj = context.active_object

    row = layout.row()
    row.label(text="Select an image", icon='WORLD_DATA')

    row = layout.row()
    row.prop(context.scene, 'select_image')


def register(): bpy.utils.register_class(SelectImagePanel) bpy.types.Scene.select_image = bpy.props.PointerProperty(name='Image',type=bpy.types.Image)

def unregister(): bpy.utils.unregister_class(HelloWorldPanel)

if name == "main": register()

custom property in the world properties window

Related questions:

Blunder
  • 13,925
  • 4
  • 13
  • 36
  • Thank you very much for your answer! I meant a specific image how to change? For example "Sky Image" from World Shader. Sorry, my python skill is very beginning – M. Gordon Dec 20 '22 at 16:25