8
$\begingroup$

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.

enter image description here

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...

panel

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

thanks for any help

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

3 Answers 3

7
$\begingroup$

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).

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ This is not quite correct, since you can control the initial ordering. (added own answer) $\endgroup$
    – ideasman42
    Jan 26, 2016 at 20:06
  • $\begingroup$ @ideasman42 What is incorect about it? The last line says that they initially show in order of registration. $\endgroup$ Jan 26, 2016 at 20:09
  • $\begingroup$ 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. $\endgroup$
    – ideasman42
    Jan 26, 2016 at 20:16
  • $\begingroup$ @ideasman42 yep true, ok $\endgroup$ Jan 26, 2016 at 20:23
2
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

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