필터 지우기
필터 지우기

How to share data with a running callback in an App Designer app?

조회 수: 4 (최근 30일)
matlabuser77
matlabuser77 2022년 3월 4일
답변: Voss 2022년 3월 4일
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?

답변 (1개)

Voss
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.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by