Page MenuHome

UILayout.box does not align correctly
Closed, ResolvedPublicTO DO

Description

In the python api it is possible to create boxes in which other properties or operators may be put. The elements of a panel can generally be aligned. But the boxes have some problems dealing with alignment. A simple script is attached with this issue to demonstrate the problem.


1. Open box_align_issue.py and run it.
2. Look at the "Hello World Panel" in the properties window in the "Object" tab.
3. Note the issues with the box alignment.

Event Timeline

looks like you used API not very correct -- i can't see where you're placing properties in the box. They're adding to layout or column in attached script. If you want property be added to box you should do the following:

box = layout.box() # create box
box.prop(...) # add property to box (place valid arguments here)

Attaching modified script which works.

All works fine with api usage i showed, so closing report. Feel free to poke me here if there'll be more issues noticed.

Hi Sergey,
yes, I know how to use the box() object and put some properties or other things in it, I use it often. I wrote this script as simple as it can be to demonstrate the issue. I was not talking about aligning properties inside a box. The bug I am describing is not present in your script.


My issue:
In fact, I was talking about aligning the box ITSELF to another object (property, operator...). If you look carefully to my example, you'll see that there is three boxes which are aligned with other properties inside a column(align=True).

The first has nothing inside of it and alignes correctly. The lower corners of the box are smoothed with the upper corners of the x location property. This is working correctly but is useless since there is nothing inside the box.

The second one does not align correctly. And the only difference between the first one is that the box is placed under the properties. The box does align with the properties, but the corners are not smoothed. Why does it smooth when it is above and not when it is under.

The third one is the same as the first one except that there is a label in it. But the simple fact to put something in the box breaks the smoothed corners.



I develped an addon where I expected a box to align smoothly with other properties. The addon is paint_palette.py it is on projects.blender.org and it is now also in the trunk. You can look at it to see an example of a situation using what I am talking about.

UIlayout.box, as an ui object, has the possibility to align itself with other ui objects inside a column or a row. It would be inconsistent to not allow it to smooth correctly as the other objects do.
Thank you for your time and considering my issue.

Pardon, nisunderstand initial issue, re-opening.

Old 2011 reports gets a bit dusty. :)

I attached "box_align_2013.py" which shows the issue. Open the script in text editor and check the panel in the scene tab.
Comment the one prop line (line 20) and the box looks fine. But in the current config it fails.

Note: the error is caused by ui_item_align() adding the buttons to the head of the list. Attempted to fix by changing the order but this just gives other similar problems.

Looks like we should really have ui_block_do_align() be able to check for adjacent boxes without them being together in the button list.

Sergey Sharybin (sergey) changed the task status from Unknown Status to Unknown Status.Jun 3 2014, 9:48 AM

There're quite enough osf things related on widgets alignment.. Perhaps at some point we'll need to revisit interface engine. For now moving to TODO http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/UserInterface#UI_Widgets

Campbell Barton (campbellbarton) changed the task status from Unknown Status to Unknown Status.EditedJan 26 2015, 4:09 PM
Campbell Barton (campbellbarton) edited a custom field.

Merged in T43286, another example of alignment failing (though not box)