GUI Button Does Not Change Colour
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Voss
il 2 Giu 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!