How to change an image (icon) on button into another one image (icon) by clicking on this button in Matlab's App Designer?

61 vues (au cours des 30 derniers jours)
Hi everyone,
This is necessary for the audio player for the play/pause button. For example, while the "play" button is pressed, an image (icon) appears on the pause button.
I don't understand how this can be added for a button. I can't find any decision to solve it. I need your help. Thank you for responce!

Réponse acceptée

Mohammad Sami
Mohammad Sami le 21 Mai 2020
You will need to do this in the callback of your button.
Assuming that when you create the button, you had set the text to Play and set the Icon file to play icon image.
function ButtonDownFcn(app,event)
switch app.Button.Text
case 'Play'
% do something to play
% change the text and icon
app.Button.Text = 'Pause';
app.Button.Icon = 'Pause.png'; % path to image file
case 'Pause'
% do something to pause
% change the text and icon
app.Button.Text = 'Play';
app.Button.Icon = 'Play.png'; % path to image file
end
end

Plus de réponses (0)

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by