GUI Button Does Not Change Colour
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi there,
I created a simple GUI using appdesginer.
As soon as I press the start button, it should change to stop, execute the code block and then change back to start. My function looks like this:
function StartButtonPushed(app, event)
tic
app.StartButton.BackgroundColor = [0.95 0.28 0.28]; % red
app.StartButton.Text = 'STOP';
% bunch of code
app.StartButton.BackgroundColor = [0.96 0.96 0.96]; % default grey
app.StartButton.Text = 'Start';
toc
end
tic/toc returns:
>> Elapsed time is 5.617925 seconds.
My button doesn't change the colour or text when Start is pressed. If I put a breakpoint in my code block, I do see the text and colour change to stop and red respectively.
Is 5s not enough gap for the button to change or am I doing somthing wrong?
Thanks for the help!
0 commentaires
Réponse acceptée
Voss
le 2 Juin 2022
Insert drawnow commands immediately after changing the Color/Text, in order to see the changes right away:
function StartButtonPushed(app, event)
tic
app.StartButton.BackgroundColor = [0.95 0.28 0.28]; % red
app.StartButton.Text = 'STOP';
drawnow();
% bunch of code
app.StartButton.BackgroundColor = [0.96 0.96 0.96]; % default grey
app.StartButton.Text = 'Start';
drawnow();
toc
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!