필터 지우기
필터 지우기

MATLAB GUI: Is it possible to change the appearance/properties of your figure if a certain action is done?

조회 수: 3 (최근 30일)
For example, I have a GUI that requires the user to input data into an edit text box. The data is the populations of each floor in a 5 floors building. However I want to have a Check Box implying "Equal floor populations?", if it is checked, I want the 5 Edit Text boxes to become one box (since the value is equal for all 5 floors). Is this possible to be done in MATLAB GUI? Note that I am new to GUI and I have only done very simple GUIs before.
Thank you in advance
Regards,
M. Ayoub

채택된 답변

Image Analyst
Image Analyst 2017년 12월 8일
Sure. In the callback of the checkbox, use something like
if handles.chkEqualFloorPopulations.Value
% Hide edit boxes 2-5.
handles.edit2.Visible = 'off';
handles.edit3.Visible = 'off';
handles.edit4.Visible = 'off';
handles.edit5.Visible = 'off';
else
% Show edit boxes 2-5.
handles.edit2.Visible = 'on';
handles.edit3.Visible = 'on';
handles.edit4.Visible = 'on';
handles.edit5.Visible = 'on';
end

추가 답변 (1개)

Rik
Rik 2017년 12월 8일
The easiest solution is to simply hide the other boxes (by setting the 'Visible' property to false).
Make sure that the callback for the box you leave visible sets the values of the other boxes to it's own value. If you do that, you wont even need to change any other logic in your code.
  댓글 수: 1
Mohammad Ayoub
Mohammad Ayoub 2017년 12월 8일
Thank you sir, your answer is the same as the accepted answer but I accepted his answer since he included an example code so that anyone who shares this problem can see it.

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

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by