To design a user friendly GUI
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 27 de Sept. de 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 comentarios
Image Analyst
el 27 de Sept. de 2013
That's not a reason for not using GUIDE. I think you didn't understand what I said.
Image Analyst
el 27 de Sept. de 2013
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
el 27 de Sept. de 2013
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!