필터 지우기
필터 지우기

How to make all the buttons of same size in matlab guide

조회 수: 4 (최근 30일)
Aash
Aash 2018년 5월 10일
답변: Walter Roberson 2018년 5월 10일
At the end of designing stage of my MATLAB gui, I want to make sure that all the buttons are of same size How
can I set all properties same?

채택된 답변

Jim Riggs
Jim Riggs 2018년 5월 10일
편집: Jim Riggs 2018년 5월 10일
Right-click on the pushbutton and open the property inspector. There you can set the exact height and width of the button (in the position field)
  댓글 수: 1
Aash
Aash 2018년 5월 10일
Oh thanks so much. I have been trying to fix it manually. YOu saved me.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2018년 5월 10일
In your gui OpenFcn callback,
buttons = findobj(hObject, 'type', 'uicontrol', '-or', 'type', 'matlab.ui.control.UIControl' );
set(buttons, 'Units', 'pixels');
for thisbutton = buttons
curpos = get(thisbutton, 'Position');
curpos(3:4) = [new_width, new_height];
set(thisbutton, 'Position', curpos);
end
There are other ways of doing this, some of which are slightly more vectorized.
Note that in each case, the bottom left corner of the button will stay fixed while the buttons get larger or smaller.
The code makes no attempt to position the buttons "nicely" to fit them between objects or aligned with objects. For example if you had
++++ ++++++++++
+Go+ + +
++++ + image +
+ +
++++++++++
and the button was made larger, then you could end up with
++++++
+ +
+ Go +
+ + ++++++++++
+ + + +
++++++ + image +
+ +
++++++++++

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by