udg, I agree with you. Setting the horizontal anchor to BOTH on the two Labels will not work!
The only way is the code suggested in post #2.
Why?
In the layout in post #1. the anchors of the two Buttons are LEFT for the left one and RIGHT for the right one.
In the original layout both Buttons cover the whole width of the Panel which has the horizontal anchor set to BOTH.
Then, if the width of the final Panel is wider than the original one the right Button is anchored to the right edge of the Panel, leaving a space between the two Buttons.
Then when you set the width of the Buttons, in the Designer Script, to half the Panel width, it's OK for the left one but not for the right one.
Why? Because, when you set the width of a view, its reference is the Left property.
The anchors are set before the Designer Script code is executed. Therefore the Designer Script doesn't take into account the anchors anymore.