To design a user friendly GUI
2 views (last 30 days)
Show older comments
Hello All
I am trying to design a GUI in which the number of radio buttons change according to the number calculated by another function. The important thing is, although I am able to get the GUI, I am not able to access the radio buttons being created. I can use gcbo. But I can't distinguish between the buttons.
for i = 1:5
handles.tr(i) = uicontrol('Style','radiobutton','String','Translation',... 'pos',[40 (1+(i*30)) 100 30],'HandleVisibility','off');
set(handles.tr(i),'Callback',@selcbk);
handles.flag_tr = 1;
handles.check_tr = 1;
end
But when I try to access the radio buttons, I can only do that using gcbo. Could you suggest some method by which I can distinguish between the buttons and hence, access them?
3 Comments
Accepted Answer
Jan
on 9 Aug 2013
The problem is not clear to me. Perhaps this helps:
handles.flag_tr = 1; % Once only
handles.check_tr = 1;
for i = 1:5
handles.tr(i) = uicontrol('Style','radiobutton','String','Translation',...
'pos',[40 (1+(i*30)) 100 30],'HandleVisibility','off', ...
'Callback',@selcbk);
end
guidata(FigureHandle, handles);
...
function selcbk(ObjectH, EventData)
handles = guidata(ObjectH);
allBoxes = handles.tr;
selectedBox = ObjectH;
otherBoxes = allBoxes(allBoxes ~= selectedBox);
3 Comments
More Answers (1)
Image Analyst
on 27 Sep 2013
How about you use GUIDE to place all of the radio buttons that you might ever need on the GUI, and then jsut set the visibility property to on or off depending if you want it to appear or not?
set(handles.radio1, 'Visibility', 'on');
set(handles.radio2, 'Visibility', 'on');
set(handles.radio3, 'Visibility', 'off');
set(handles.radio4, 'Visibility', 'off');
6 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!