I have been working through several tutorials on scripting new ui elements and panels. However, there are two problems I have not been able to solve. The first is how to control where your new ui element will show up in a panel. For example, if I do the following:
class DemoPanel(bpy.types.Panel):
bl_label = "My new Panel"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "texture"
This places a new ui element in the texture panel which is great, but how do I go about say placing it at that top of the list instead of at the bottom, or anywhere inbetween. I realize that I change the order by hand by dragging and dropping but is there a way do it through the python script. My second question is kind of related to the first and that is to find out if it is possible to place a new ui element in a specific section of a pallet. Right now when I run the above code my new ui element is present in the texture panel regardless of what I might be doing at the time. However, what I would like to do is say place a button only in the section of the panel that deals with image textures. See attached image. I realize that I can do this in properties_texture.py. But I would like to be able to do this from my script. Any ideas on how to do this would be greatly appreciated.