GUI: Make pannel visible/invisible with buttonpress

Dear all,
I want to make an initially invisible pannel visible on the first button push, and invisible again by pressing the button again... I know this should be simple, but for some reason it is not working out. Here is my code:
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if get(handles.pushbutton2,'value') == 0
set(handles.uipanel2,'visible','on')
set(handles.pushbutton2,'value',1)
end
if get(handles.pushbutton2,'value') == 1
set(handles.uipanel2,'visible','off')
set(handles.pushbutton2,'value',0)
end

 Respuesta aceptada

Image Analyst
Image Analyst el 21 de Sept. de 2014

0 votos

Typo: handles.pushbotton2 is not the same as handles.pushbutton2

4 comentarios

Marcel
Marcel el 21 de Sept. de 2014
can you elaborate a litte bit more?
Marcel
Marcel el 21 de Sept. de 2014
Oh, I fixed this error, still does not work
Image Analyst
Image Analyst el 21 de Sept. de 2014
Instead of setting a value for the button, just retrieve the "visible" property of the panel itself. Check it with strcmpi() and take action based on it's current value to toggle it.
Marcel
Marcel el 23 de Sept. de 2014
awesome, the strcmpi() worked! I compared the visibility of pannel_1 with pannel_2 ! :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Sept. de 2014

Comentada:

el 23 de Sept. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by