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

Melvin
Melvin 2012년 2월 24일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

G A
G A 2012년 2월 24일

0 개 추천

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

댓글 수: 8

Melvin
Melvin 2012년 2월 24일
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 2012년 2월 24일
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 2012년 2월 24일
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 2012년 2월 24일
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 2012년 2월 24일
I have edited the code above
Melvin
Melvin 2012년 2월 25일
what changes have you made?
G A
G A 2012년 2월 27일
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 2017년 5월 16일
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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

질문:

2012년 2월 24일

댓글:

2017년 5월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by