UI: Append/Prepend a entire panel

Hi everybody !

I’m searching how to prepend a panel class. I can append (draw it after existing UI) or prepend ( draw before existing UI) a draw like this :


import bpy

def test(self,context):
    layout = self.layout       
    row = layout.row()
    row.label(text="Hello world!")

def register():
    bpy.types.PARTICLE_PT_context_particles.append(test)
if __name__ == "__main__":
    register()

But I don’t know how for a panel class like this:


class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "particle"

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

        obj = context.object

        row = layout.row()
        row.label(text="Hello world!")



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

if __name__ == "__main__":
    register()


The first code put the text on top of the Particle tab but somebody know how to do the same with the second code ?

thanks

nobody have a idea ?

you either append something to draw to an existing panel like in your first code snippet. Or you do your own panel. Why would you want to create a custom panel and append/prepend it to an existing one? It’s not possible, it would give you a panel inside of another panel.

you could re write the UI script for that panel!

not the best option but could work !

salutations

what exactly I’m want to do is to put my panel ontop of the particle tab , not in the bottom.
Ontop or between two existing panels. But it’s not seem possible.

Yes ,RickyBlender, your right, rewrite and replace existing panel can be a solution but not the best.

CoDemanx , thanks for the link but the first solution is exactly what I’m doing in my first example and second solution is like what RickyBlender talk about.

i found an example in my notes
but never really tried it
could work



mport bpy

def test(self,context):
    layout = self.layout       
    row = layout.row()
    row.label(text="Hello world!")

def register():
    bpy.types.PARTICLE_PT_context_particles.append(test)
if __name__ == "__main__":
    register()




but again this might be valid only for operator not panel!

may be take a chance on IRC blenderpyton might be lucky

salutations

1 Like

hummm … it’s seem to be a copy/paste of my example in the first post no ? :rolleyes:

This is work but it’s not create a panel , it’s just add some draw to a existing one :slight_smile:

was looking in my notes file and found this simple example for adding in draw function

if you ask on irc you might get lucky!

but don’t really remember anything for panels as such
seen another example for items with a menu but not for a panel!
panels are taken care by the GUI in blender internal and no control over it

did not follow but there is this GSOC project on GUI which might give more control for panels maybe!
check it out

happy blendering

thanks, hope somebody on irc have the answer. If not , I must to cheap it or just accept that my panel goes in the bottom.

appending and prepending is just to extend an existing panel, it influences the draw method of that panel. You must not use this to place your own panel at the top.

Where a panel shows up, seems to be related to the order of script loading. bl_ui scripts are therefore at the very top, and (most) addon panels at the bottom. There is currently no way to change this order but to move them with the mouse.