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

1 vue (au cours des 30 derniers jours)
matlabuser77
matlabuser77 le 4 Mar 2022
Réponse apportée : Voss le 4 Mar 2022
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?

Réponses (1)

Voss
Voss le 4 Mar 2022
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.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by