In the add-ons I am writing, I can only put one entity per line. I would like to be able to put multiple of them in one row. Is there something that allows me to do this?
The image from ArchiMesh is what I am aiming for:
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityPerhaps the easiest way to have a 2 column layout is using the column_flow
layout, set to 2 columns.
Replacement draw method for Text Editor > Templates > Python > UI Panel Simple
11 add cube operator buttons by way of example
def draw(self, context):
layout = self.layout
cf = layout.column_flow(columns=2, align=False)
for i in range(11):
cf.operator("mesh.primitive_cube_add")
Changing to 3 columns.
To create multiple entities in a row, you need to use layout.row()
.
What layout.row()
does is it essentialy tells Blender that you are focusing on a single row. Every prop, operator, etc you put after layout.row()
will be in that row until you put another layout.row()
, telling Blender to focus on the next row.
Here is an example:
layout = self.layout()
row = layout.row() # Focus on this row
row.prop(prop, "property") # Add a property
row.operator("operator") # Adds an operator in the same row as the property.
row = layout.row() # A new row
and properties here will be on a separate row.
You can also do
row = layout.row(align = True)
to make the borders of entities flush with each other.
layout.row()
then populate that row with your operators. See : blender.stackexchange.com/a/58368/86891 and you should look into theui_panel.py
script template available directly in the text editor $\endgroup$