Borrar filtros
Borrar filtros

Radio Buttons in panel

2 visualizaciones (últimos 30 días)
Vivek
Vivek el 8 de Abr. de 2014
Comentada: Vivek el 9 de Abr. de 2014
I created two radiobuttons on panel in GUI through script.I can select both at the same time (ie) selection is not removed when another radio bttn is selected.
Even I checked the parent of both radio button. It is same.
f1=get(findall(0,'Tag','English0'),'Parent')
f2=get(findall(0,'Tag','Metric1'),'Parent')
f1 and f2 both are same Then why a normal radio buttons functionality in single panel is not achieved?
Please suggest ideas.

Respuesta aceptada

Matt Tearle
Matt Tearle el 8 de Abr. de 2014
Panels are basically just cosmetic. Use a uibuttongroup to manage the exclusivity behavior you want. Compare:
figure
pnl = uipanel('position',[0.1 0.1 0.5 0.5]);
b1 = uicontrol('parent',pnl,'units','normalized','position',[0.1 0.1 0.8 0.4],...
'style','radiobutton','string','I am a choice');
b2 = uicontrol('parent',pnl,'units','normalized','position',[0.1 0.5 0.8 0.4],...
'style','radiobutton','string','I am a choice');
versus
figure
pnl = uibuttongroup('position',[0.1 0.1 0.5 0.5]);
b1 = uicontrol('parent',pnl,'units','normalized','position',[0.1 0.1 0.8 0.4],...
'style','radiobutton','string','I am a choice');
b2 = uicontrol('parent',pnl,'units','normalized','position',[0.1 0.5 0.8 0.4],...
'style','radiobutton','string','I am a choice');
  3 comentarios
Matt Tearle
Matt Tearle el 8 de Abr. de 2014
You don't have to specify parents to most graphical objects, but it's a recommended practice because it ensures that things end up where you expect them to. In this case, you really want the radio buttons to be inside the button group, because that manages the exclusivity.
Vivek
Vivek el 9 de Abr. de 2014
@ salaheddin: Imagine such a situation where you want to hide a set(say >20) of buttons and unhide a different set of buttons.
In this case, hiding/unhiding its parent is enough. So always recommended to create buttons for single requirement at panel(parent).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by