필터 지우기
필터 지우기

Using the Matlab App Designer, How can I hide a numeric field with a button push?

조회 수: 23 (최근 30일)
Garrett Douglas
Garrett Douglas 2018년 7월 11일
답변: Freya H 2018년 8월 13일
I have been attempting to use the Matlab App Designer to create a program GUI. I want to have a button with two options, A or B. If A is selected, a numeric box will pop up with a label, and that numeric will have a variable corresponding to A. If B is selected, I want a different numeric box to pop up, and this box would have a variable associated with B. I am trying to do this within a tab, and do not want to use the figure command as this has created a pop up window. Utilizing an If statement, I have been able to get the boxes to pop up, but if I select button A, and then button B, The button A box does stays open, and the text overlaps. Thank you in advance. App Code Attached:
button = app.ButtonGroup.SelectedObject.Text;
if button(1) == 'A'
% Create EditFieldLabel
appEditFieldLabel = uilabel(app.InputsTab);
appEditFieldLabel.HorizontalAlignment = 'right';
appEditFieldLabel.Position = [210 572 50 15];
appEditFieldLabel.Text = 'A';
% Create EditField
appEditField = uieditfield(app.InputsTab, 'numeric');
appEditField.Position = [275 568 100 22];
delete appEditFieldLabel1
else
% Create EditFieldLabel
appEditFieldLabel1 = uilabel(app.InputsTab);
appEditFieldLabel1.HorizontalAlignment = 'right';
appEditFieldLabel1.Position = [210 572 50 15];
appEditFieldLabel1.Text = 'B';
% Create EditField
appEditField1 = uieditfield(app.InputsTab, 'numeric');
appEditField1.Position = [275 568 100 22];
end

답변 (1개)

Freya H
Freya H 2018년 8월 13일
You can set the visibility of the other label to 'off' using
app.NameofComponent.Visible = 'off'
I would create both components outside the function (e.g. in the design view) and set their visibility to 'off' (e.g. in the startupfcn).
You can then set the visibility of the component you want to show to 'on' in each of your if/else statements (and the other one to 'off').

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by