Radio buttons in GUI
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael Adelman
am 10 Jul. 2012
Kommentiert: Andy
am 18 Apr. 2015
HI,
I have two radio buttons in GUI. I want to make that only one button can be pressed at a time. what is the best way do it?
thanks,
1 Kommentar
Andy
am 18 Apr. 2015
A Button Group panel is the best way make button selections exclusive. Here is a tutorial on how to do it: https://codemusician.wordpress.com/2013/03/15/gui-tutorial-how-to-create-and-use-radio-button-groups-in-matlab/
Akzeptierte Antwort
Honglei Chen
am 10 Jul. 2012
Bearbeitet: John Kelly
am 26 Feb. 2015
You may want to use button groups
0 Kommentare
Weitere Antworten (3)
Jan
am 10 Jul. 2012
I prefer to control this manually:
handles.FigureH = figure;
handles.radio(1) = uicontrol('Style', 'radiobutton', ...
'Callback', @myRadio, ...
'Units', 'pixels', ...
'Position', [10, 10, 80, 22], ...
'String', 'radio 1', ...
'Value', 1);
handles.radio(2) = uicontrol('Style', 'radiobutton', ...
'Callback', @myRadio, ...
'Units', 'pixels', ...
'Position', [10, 40, 80, 22], ...
'String', 'radio 2', ...
'Value', 0);
...
guidata(handles.FigureH, handles);
And the callback:
function myRadio(RadioH, EventData)
handles = guidata(RadioH);
otherRadio = handles.radio(handles.radio ~= RadioH);
set(otherRadio, 'Value', 0);
0 Kommentare
Michael Adelman
am 10 Jul. 2012
Bearbeitet: Michael Adelman
am 10 Jul. 2012
3 Kommentare
Jan
am 11 Jul. 2012
@Micheal: Please read the instructions for formatting code in this forum. E.g. the "About Matlab Answers" would be a good point to start from.
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!