How I make a pushbutton visible using another pushbutton in a GUI?

"Pushbutton 1" shows and work with graphical data essential to the "pushbutton 2" subprogram task. Pushing "pushbutton 2" before "pushbutton 1" leads to error. I want to make "pushbutton 2" inaccesible in the GUI until user press "pushbutton 1". How can I do it?

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 5 de Nov. de 2013
Editada: Azzi Abdelmalek el 5 de Nov. de 2013
You can use the properties 'enable' or 'visible'
set(handles.pushbutton1,'enable','off')
%or
set(handles.pushbutton1,'visible','off')

3 comentarios

CarlosCEAM
CarlosCEAM el 5 de Nov. de 2013
Editada: CarlosCEAM el 5 de Nov. de 2013
In property inspector I set pushbutton 2 as "off", and then I have this code:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
set(handles.pushbutton2, 'enable','on')
The button shows grayed out, but pushing "pushbutton 1" doesn't make any change on "pushbutton 2". Am I missing something?
Set a breakpoint there and see if it actually executes that line. You can also use the 'visible' property to hide it or show it. Enable property enables or disables (grays out) the button. You might also try adding a drawnow after the set() call though it should not be necessary.
Azzi Abdelmalek
Azzi Abdelmalek el 5 de Nov. de 2013
Editada: Azzi Abdelmalek el 5 de Nov. de 2013
Don't forget to save your m-file

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Preguntada:

el 5 de Nov. de 2013

Editada:

el 5 de Nov. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by