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.

 채택된 답변

Bruno Luong
Bruno Luong 2020년 11월 6일
편집: Bruno Luong 2020년 11월 6일

2 개 추천

"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

Marco
Marco 2020년 11월 6일
편집: Marco 2020년 11월 6일
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!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

릴리스

R2016a

질문:

2020년 11월 6일

편집:

2020년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by