How to share data with a running callback in an App Designer app?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have an App Designer app that executes a while loop (within a callback) once a button is pressed. I want the user to be able to change configurable parameters in the GUI (e.g. a spinner or an edit field) and have those updated values get used by the code currently executing within the while loop running in the original callback.
I've tried having the while loop code read the app.SpinnerName.Value, but this value seems to stay static (from the perspective of the while loop) even though the user can change this value in the GUI while the while loop is executing. I believe this is because the "app" structure that gets passed into the original button callback is a copy of the actual app structure. Is there a way to update or refresh this "app" structure within an executing callback?
I've contemplated alternative approaches to feeding that value in, such as having the SpinnerNameValueChanged callback write the value to a file or perhaps to the base workspace, then having the executing callback read the new value from there (instead of from the app structure), but this strikes me as clunky/inefficient. Any suggestions?
댓글 수: 0
답변 (1개)
Voss
2022년 3월 4일
Try including a drawnow() inside your while loop, which will update the graphics so that when subesquent code gets the value of a property of a UI component, the value is up-to-date.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!