Blender API (2.6), UI list of loaded images I'm trying to make something like map editor for my project. I'm rather new in Blender Python scripting and I have some troubles.

I made "Material" panel and I want to set "textureName" property for my object. What I need is to make some list of loaded in blender images (like in UV Editor you can load image and it appears on list). 

In my panel I want just to choose one image and assign name of that image to my property. I can list loaded images by bpy.data.images but I can't dynamically add new images to property (for now I'm using EnumProperty assigned to bpy.types.Object.textureName). I was trying to make same UI widget like blender have (http://i.imgur.com/6VJVAsN.png) but I have no idea how it works.

Can somebody help me with this?
Adding a "real" datablock widget won't quite work and it's not possible (or at least not easy) to have a dynamically populated EnumProperty object. Fortunately, there is the prop_search() UILayout function. You can use that to assign the name of a datablock to a StringProperty variable. So, you should have something along the lines of this for that StringProperty:

bpy.types.Object.textureName = bpy.props.StringProperty(name="Texture")


With that done, all objects now have a new string property called textureName that defaults to an empty string. Now, in your panel, add something akin to the following in the draw() function:

def draw(self, context):
    ob = context.active_object

    layout = self.layout
    layout.prop_search(ob, "textureName", bpy.data, "images")


Of course, this only assigns the name of the texture to that StringProperty variable. You still need to write code that does something with this property.