# How I can define the order of the panels?

at this moment I have I tag with many panels

I do some folder and some __init__.py in order to import all the addons at the same time in the blender's addons_contrib folder.

I did that __init__.py and the main OrigamiPanel.py at the same order that I want the panels, but the panels aren't in the correct order...

all the code work fine, but ... How I can define the order of the panels?

thanks for any help

• Well, you can't, its not exposed to the python API. – Jaroslav Jerryno Novotny Jan 31 '15 at 9:59
• You can drag them into the order you want and then saving the startup file should keep the order. – sambler Feb 1 '15 at 7:29
• @samler yes, but that is not the original idea – yhoyo Feb 1 '15 at 13:44

As a script author you have limited control of panel ordering.

• You can change the initial order they show in relation to each other.
(for multiple panels you define)
• You can't change the order they display in relation to other panels
(defined by other scripts for example).
• You can't change the order of panels in existing blend files
(see workaround below *).

Panels are shown in the order they are registered,

This means if you use bpy.utils.register_module(__name__) the order they're defined.

Since having to re-arrange code just to change panel order is inconvenient. You can register each class explicitly with bpy.utils.register_class(cls), and re-arrange the order of registration this way. See example.

Note that once the panels are saved in a file - their order is saved too. To ignore the saved order you will you will need to load the blend with Load UI disabled.

* You can workaround this and ignore saved panel location in existing files - by renaming the class. (admittedly a kludge).

Currently the Python API can't handle panel ordering at runtime (it's not exposed).

Blender philosophy is that in general python scripts should not care about where panels are. It's only in the hands of user.

Panels get added in order of their registration, but user can reorder them anytime and this order will be saved and used.

• This is not quite correct, since you can control the initial ordering. (added own answer) – ideasman42 Jan 26 '16 at 20:06
• @ideasman42 What is incorect about it? The last line says that they initially show in order of registration. – Jaroslav Jerryno Novotny Jan 26 '16 at 20:09
• Now we get into details - I mean its not correct to say it "cant handle panel ordering". At run time - correct, but initial ordering can be set, went into some more details about this in my answer. – ideasman42 Jan 26 '16 at 20:16
• @ideasman42 yep true, ok – Jaroslav Jerryno Novotny Jan 26 '16 at 20:23

Your custom panels will be added in the order that they are registered during the register phase of your addon. If you're using bpy.utils.register_module(__name__) then that will register the classes in order of appearance in the file.

If other add-ons load later, then their panels get appended below yours. There is no functionality (May 2015) to determine a-priori where on a tool-bar your panels appear, at most the order.