Borrar filtros
Borrar filtros

How to update GUI in matlab App during a callback

78 visualizaciones (últimos 30 días)
Timo
Timo el 21 de Abr. de 2022
Comentada: Hiro Yoshino el 21 de Abr. de 2022
Hello
Environement: matlab R2021b and R2021a, windows 10
I would like to change the color of a button during a callback in an Matlab App created with the App Designer.
% Button pushed function: LoadButton
function LoadButtonPushed(app, event)
set(app.LoadButton,'BackgroundColor',[1, 0, 0])%set color of the button to red
%... do things..
set(app.LoadButton,'BackgroundColor',[0, 1, 0])%set color of the button to green
end
I see only the green button in the end, but not the red button while the callback function is running. It seems that there is something like a refresh or update, somthine like guidata in GUIDE is needed.
How do I update the user interface inbetween?
Many thanks and best wishes

Respuesta aceptada

Bruno Luong
Bruno Luong el 21 de Abr. de 2022
Try to force refresh with drawnow
% Button pushed function: LoadButton
function LoadButtonPushed(app, event)
set(app.LoadButton,'BackgroundColor',[1, 0, 0])%set color of the button to red
drawnow
%... do things..
set(app.LoadButton,'BackgroundColor',[0, 1, 0])%set color of the button to green
drawnow
end
  4 comentarios
Timo
Timo el 21 de Abr. de 2022
Editada: Timo el 21 de Abr. de 2022
Works perfectly. Many thanks Bruno!
Hiro Yoshino
Hiro Yoshino el 21 de Abr. de 2022
Wow it's great ☺

Iniciar sesión para comentar.

Más respuestas (1)

Hiro Yoshino
Hiro Yoshino el 21 de Abr. de 2022
the changes made by valuChanged callback functions are reflected later. If you want to see the changes dinamically, you should use valuChanging callback functions.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by