Initially Disabled Button Group when using GUI / GUIDE

10 visualizzazioni (ultimi 30 giorni)
Hello all,
I have an easy GUI question that I can't find the answer to - I can't figure out where to specify that a button group is initially disabled instead of enabled.
In my simplified example, I want to have a check-box that has a disabled (greyed-out) button group below it, until the check-box is selected by the user.
I have gone over similar questions in the forum, and I have found that the way to change the status of the button group is:
function MattsCheckBox_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
set(findall(handles.MattsButtonGroup, '-property', 'enable'), 'enable', 'on');
else
set(findall(handles.MattsButtonGroup, '-property', 'enable'), 'enable', 'off');
end
When I click back and forth on the check-box, sure enough my button group enables and disables. However, before I do any clicking of the check box, the button group starts enabled instead of disabled. Where (or how) do I initialize the button group so that it starts disabled and greyed-out?

Risposta accettata

Matt C
Matt C il 8 Set 2016
I figured it out. There isn't any default disablement of the Button Group - it needs to be coded into the disabled position at the beginning of the code under the _OpeningFcn function. Here is the code:
function MattsTestScript_OpeningFcn(hObject, eventdata, handles, varargin) % Default line produced by GUIDE
handles.output = hObject; % Default line produced by GUIDE
guidata(hObject, handles); % Default line produced by GUIDE
set(findall(handles.MattsButtonGroup, '-property', 'enable'), 'enable', 'off'); % HERE IT IS

Più risposte (1)

mbonus
mbonus il 8 Set 2016
If the value you are checking in the if statement is true when the GUI starts up, that may be causing the button group to start enabled. For the check box set the value property to 0. Also check to make sure the button group is initialized to 'enable' 'off'. From Guide you should be able to right click the objects and changer their properties, I believe if you hardcode it during the initialization in the code it will work as well, not sure because I don't use Guide.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by