2
$\begingroup$

How do I add a panel to the properties region in the image editor? The code below is just a slight modification from the "ui_panel_simple.py" template. I changed the bl_space_type to be the text editor, and the bl_region_type to be UI which I thought would put it in the properties region, but it does not work.

import bpy

class HelloWorld(bpy.types.Panel):
    """Creates a Panel in the Text Editor properties region"""
    bl_label = "Hello World"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'TEXT_EDITOR'
    bl_region_type = 'UI'

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

        row = layout.row()
        row.label(text="Hello world in the text editor!", icon='WORLD_DATA')

def register():
    bpy.utils.register_class(HelloWorld)

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

if __name__ == "__main__":
    register()
$\endgroup$
1
  • 2
    $\begingroup$ Your code works for me, the label is displayed in the text editors property panel accessible by Ctrl-T $\endgroup$
    – stacker
    Mar 7, 2015 at 19:49

1 Answer 1

5
$\begingroup$

The script works as written. The "problem" with the script is that it is putting the hello world in the text editor and not the image editor. bl_space_type takes:

EMPTY, VIEW_3D, GRAPH_EDITOR, OUTLINER, PROPERTIES, FILE_BROWSER, IMAGE_EDITOR, INFO, SEQUENCE_EDITOR, TEXT_EDITOR, DOPESHEET_EDITOR, NLA_EDITOR, TIMELINE, NODE_EDITOR, LOGIC_EDITOR, CONSOLE, USER_PREFERENCES

as accepted values, one for each window type in blender. The script in question has TEXT_EDITOR and not IMAGE_EDITOR.

import bpy

class HelloWorld(bpy.types.Panel):
    """Creates a Panel in the Image Editor properties region"""
    bl_label = "Hello World"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'IMAGE_EDITOR'
    bl_region_type = 'UI'

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

        row = layout.row()
        row.label(text="Hello world in the image editor!", icon='WORLD_DATA')

def register():
    bpy.utils.register_class(HelloWorld)

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

if __name__ == "__main__":
    register()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .