How to modify the text visibility in a Gui that created using App Designer

Dear Coder,
I have develop a gui using AppDeveloper.
In a separate main.m file, I would like to display the GUI and change the visibility of a Label. Say the component having name of app.Label.
If using GUIDE, I know the command to achieve this will be
set(handles.LabelTag,'Visible','off');
But having migrated to App Developer, the command is not working.
Some method in the net show that the code should be something like below, however, its is not working for my case.
app.Label.Visible = 'off'
Appreciate if someone can show which part i do wrong

 채택된 답변

Ajay Kumar
Ajay Kumar 2020년 1월 21일
편집: Ajay Kumar 2020년 1월 21일
What is the exact name of the component? I would suggest you to rename it if its only Label.
For example, if you rename it to Component1EditField, then to change the visibility, you can use:
app.Component1EditFieldLabel.Visible = 'off';

댓글 수: 6

Thanks for the quick reply.
However, the propsed line does not work as intended.
FYI, Im having two files. 1) GuiApp.mlapp and 2) GuiApp.m.
Then, in the GuiApp.m, I would like to display the figure and change the visibility of the component, This is achieve as follow
GuiApp () % To execute and display the figure
app.Component1EditFieldLabel.Visible = 'off'; % To make the component invisible
However, Im not able to make the component invisible using the line suggested above.
Do you know where I do wrong?
Thanks
"Then, in the GuiApp.m, I would like to display the figure and change the visibility of the component"
Are you returning app from GuiApp.m and passing app as attributes to the same? i.e.
Is your first line of GuiApp.m is:
function [app] = GuiApp(app)
?
If not Please make it this way.
This makes sure that you have access to the app components from the .m file as well.
Also, in the code you have written above, make a small change.
GuiApp(app); % To execute and display the figure % add app in brackets
app.Component1EditFieldLabel.Visible = 'off'; % To make the component invisible
Hi Ajay, appreciate for the helps. But, I still not able to make thing work though amend the code according to your suggestion.
Can you have a look at the code accessvle from this link, whether it is correct or not. FYI, Im using MATLAB R2019b.
Thanks once again for your time entertaining this request
Ok, this is a different context now.
Replace the whole main.m file with
x = GuiApp;
x.Component1EditFieldLabel.Visible = 'off';
Hi Ajay,
Thanks for the suggestion, it work like charm.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

2020년 1월 21일

댓글:

2020년 1월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by