Radio Button and Panel GUIDE

What code should i write under a callback of the radio button when you want to click a radio button, the visibility of the panel is being controlled. Radio button clicked, Panel appears. Radio Button unclick, panel hides...what do you think? Thank you everyone

1 Commento

Melvin
Melvin il 24 Feb 2012
the panel---i mean a panel you created on a gui...so only two objects are present on the gui. The radio button and a panel...thank you

Accedi per commentare.

Risposte (1)

G A
G A il 24 Feb 2012

0 voti

if (get(hObject,'Value') == get(hObject,'Max'))
set (handles.my_uipanel,'Visible','on');
else
set (handles.my_uipanel,'Visible','off');
end

8 Commenti

Melvin
Melvin il 24 Feb 2012
i tried this but still it doesn't work, what do you think is wrong? or am i missing something else?
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
if get(hObject,'Value')
set (handles.panelgen,'Visible','on');
else
set (handles.panelgen,'Visible','off');
end
Melvin
Melvin il 24 Feb 2012
but it worked when i used a checkbox instead of a radiobutton...does the button group caused my problem? since i used a button group for my radiobutton...
G A
G A il 24 Feb 2012
may be you have to use this line:
if (get(hObject,'Value') == get(hObject,'Max'))
"Radio buttons set Value to Max when they are on (when selected) and Min when off (not selected)."
http://www.mathworks.co.uk/help/techdoc/creating_guis/f16-999044.html#f16-1003665
Melvin
Melvin il 24 Feb 2012
i used this, and it worked...
function uipanel5_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel5
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'radiogen'
% Code for when radiobutton1 is selected
set (handles.panelgen,'Visible','on');
set (handles.panelmot,'Visible','off');
case 'radiomot'
% Code for when radiobutton2 is selected.
set (handles.panelmot,'Visible','on');
set (handles.panelgen,'Visible','off');
otherwise
% Code for when there is no match.
end
G A
G A il 24 Feb 2012
I have edited the code above
Melvin
Melvin il 25 Feb 2012
what changes have you made?
G A
G A il 27 Feb 2012
Instead of checking for Value 1 or 0 (true or false), for radio button you have to check for Value 'Max' or 'Min'
asma arafat
asma arafat il 16 Mag 2017
hello, i want to show panel with some texts when i click push button only and hide it when i am not click it. any help? thanks

Accedi per commentare.

Categorie

Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange

Tag

Richiesto:

il 24 Feb 2012

Commentato:

il 16 Mag 2017

Community Treasure Hunt

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

Start Hunting!

Translated by