0
$\begingroup$

I followed the tutorial for making a custom space in C code, from the tutorial in this question Creating own editor type.

I succeeded but it seems that it has no header and no combo box with the list of other spaces. If I try to run template scripts to create panels and switch the bl_space_type to the name of my editor the script runs with no errors but the controls don't show up. So I am interested in how to insert header, combo box and generally make it work like other spaces with the Python API. A python based solution is preferable but, at this point, I would welcome any.

$\endgroup$
2

1 Answer 1

0
$\begingroup$

I am not sure how much of this is necessary but I did some intuitive edits on the code and it works, if anyone can explain exactly why I would be most grateful.

Go to the /home/user/blender-git/build_linux/bin/2.79/scripts/startup/bl_ui(respective to your system) folder where all the other editor *.py startup files are copy space_info.py, rename it to space_yourspace.py.

In the same folder find the __init__.py open it and add space_yourspace to the constant _modules, this will make blender run said module on startup, so be sure to edit the file before starting it up.

Now open up space_yourspace.py and delete everything from INFO_MT_editor_menus.draw_collapsible(context, layout) down to, but not including classes = (.

Now in the classes tuple delete everything except INFO_HT_header, be sure to leave one comma after INFO_HT_header so it remains a tuple and not just a pair of parenthesis. Rename INFO_HT_header to YOURSPACE_OT_header in the tuple.

Go back to the remaining class and rename it also to YOURSPACE_OT_header.Inside the class change the value of static variable bl_space_type to 'YOURSPACE_EDITOR'. After this, you can start Blender and in the header of yourspace you will have the said combo box.

$\endgroup$
1
  • $\begingroup$ While the main area of an editor is implemented in C/C++, all of the UI widgets are controlled using python. The bl_ui/space_yourspace.py is the file blender finds to use for a yourspace editor, without it there are no regions displayed around the editor. Similar naming conventions are used to find the code to use - YOURSPACE_HT_header for the header, while bl_space_type needs to be set for panels that belong to that editor, this is the same as setting it for any custom panels you add to existing editors. $\endgroup$
    – sambler
    Sep 9, 2017 at 4:59

You must log in to answer this question.

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