A short question regarding the pushbutton in GUI

I am new to the GUI design. Any help will be highly appreciated!!
I am trying to use a pushbutton/toggle button in my GUI. Basically I want it to be like intially display 'off', and when I click it, it will display 'on', and click it again, then 'off' again.
Thank you!!

1 comentario

Jan
Jan el 25 de Feb. de 2012
What exactly is your question? Are you using GUIDE? What have you tried already an which problems occurred?

Iniciar sesión para comentar.

 Respuesta aceptada

Jan
Jan el 25 de Feb. de 2012
A small example:
uicontrol('Style', 'togglebutton', 'String', 'off', ...
'Value', 0, ...
'Callback', @myToggleCallback);
function myToggleCallback(ButtonH, EventData)
if strcmp(get(ButtonH, 'String'), 'off')
set(ButtonH, 'String', 'on');
else
set(ButtonH, 'String', 'off');
end

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 25 de Feb. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by