Equivalent to guidata in App Designer

10 ビュー (過去 30 日間)
William Day
William Day 2022 年 3 月 30 日
編集済み: Walter Roberson 2023 年 11 月 10 日
I converted a GUIDE based applicatoin to App Designer. When I created a new variable in a callback, I would add it to handles. Then at the end of the callback I would issue a guidate command so that my new variable was accessible in other callbacks of the GUI. Example
handles.cpu_str = cpu_str;
guidata(myapp,handles)
The help tells me to not use guidata except with GUIDE and .fig. So how do I make these variables available? The help advised me to change my handles to app.handles, but this had no effect. I tried making a handles a public property. How should I do this
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 3 月 30 日
William Day
William Day 2022 年 3 月 31 日
Thanks Walter. I have figured it out. I did in fact use the migration tool. It creates a command like this at the start of all callbacks.
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event);
So my problem was the hObject in the command. I changed it as follows
[hObject, eventdata, app.handles] = convertToGUIDECallbackArguments(app, event);
and changed the guidedata command to and then it worked fine
guidata(hObject,app.handles]
I think that maybe the help should clarify that guidata can still be used in App Designer if it was migrated from GUIDE

サインインしてコメントする。

採用された回答

William Day
William Day 2022 年 3 月 31 日
Thanks Walter. I have figured it out. I did in fact use the migration tool. It creates a command like this at the start of all callbacks.
[hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event);
So my problem was the hObject in the command. I changed it as follows
[hObject, eventdata, app.handles] = convertToGUIDECallbackArguments(app, event);
and changed the guidedata command to and then it worked fine
guidata(hObject,app.handles]
I think that maybe the help should clarify that guidata can still be used in App Designer if it was migrated from GUIDE
  2 件のコメント
Jeffrey Topp
Jeffrey Topp 2023 年 11 月 9 日
I have a similar issue. I created an app in App Designer which has a button that calls a script. How do I access the data (equivalent to guidata) from inside my script? I'd rather not pass the status off all the checkboxes and what not into the script.
Walter Roberson
Walter Roberson 2023 年 11 月 10 日
編集済み: Walter Roberson 2023 年 11 月 10 日
You would have to make sure that all of the properties of the app are Public so that you can examine them off of app. from inside your script. If you want to prevent the script from changing the properties, you would need to mark the properties as not having write access.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by