GUI - Align "Distribute" option does not work

Dear community,
I'm creating a basic GUI where I have inserted a panel and two push buttons.
I would like to uniformly distribute the two pushbuttons inside the panel on the vertical dimension, but the align "distribute" option doesn't work. In fact, the GUI shows the buttons one superimposed to the other (I only see the 2nd button, the 1st is hidden under the 2nd).
Here is the code:
function Global_configuration = UI_Configuration( Global_configuration )
main_UI = figure('Visible','on','Name','UI Configuration', ...
'NumberTitle','off', 'MenuBar','none', ...
'Position',[500 300 600 600]);
main_panel = uipanel(main_UI,'Title','Configure analysis', ...
'Position',[.05 .25 .90 .70]);
b_Configure_simulation = uicontrol(main_panel,'Style','pushbutton', ...
'String','Configure Simulation', ...
'Units','normalized', ...
'Position',[.1 .3 .8 .2], ...
'Callback',{@Configure_Sim, main_UI});
b_Configure_output = uicontrol(main_panel,'Style','pushbutton', ...
'String','Configure Output', ...
'Units','normalized', ...
'Position',[.1 .3 .8 .2], ...
'Callback',{@Configure_Out, main_UI});
align([b_Configure_simulation b_Configure_output],'Center','Distribute');
end
What am I doing wrong?
Thank you in advance.

 Respuesta aceptada

Bruno Luong
Bruno Luong el 6 de Nov. de 2020
Editada: Bruno Luong el 6 de Nov. de 2020

2 votos

"I would like to uniformly distribute the two pushbuttons inside the panel on the vertical dimension, but the align "distribute" option doesn't work. In fact, the GUI shows the buttons one superimposed to the other (I only see the 2nd button, the 1st is hidden under the 2nd)."
I think you miss-understand how align supposes to work. It won't distribute to fill the container. It fill the extreme original y positions of your objects. It's clearly written in the doc. In your case the button won't move since the original y position are identical.

1 comentario

Marco
Marco el 6 de Nov. de 2020
Editada: Marco el 6 de Nov. de 2020
You're right, I was totally misunderstanding how the function works despite having read the documentation several times. I've now tried to include different y-positions for the objects and it works distributing the objects within the y-positions boundaries.
Thanks a lot!

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2016a

Preguntada:

el 6 de Nov. de 2020

Editada:

el 6 de Nov. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by