To design a user friendly GUI
이전 댓글 표시
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?
채택된 답변
추가 답변 (1개)
Image Analyst
2013년 9월 27일
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
Image Analyst
2013년 9월 27일
That's not a reason for not using GUIDE. I think you didn't understand what I said.
Image Analyst
2013년 9월 27일
Yes, if the most buttons you can ever have is, say, 25, then put 25 on there. In the opening fcn you can put the handles of the radio buttons into an array (just like Jan did). Then, say, a popup (drop down list) callback indicates that you should have 10 showing. So you then run a loop (like Jan did) where you set the visibility of radio buttons 1-10 "on", and 11-25 "off". But anyway, it looks like you're successfully using Jan's method so you're all set. Jan is a fan of the do-it-yourself method while I'm a fan of the GUIDE method.
nl2605
2013년 9월 27일
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!