How do I initialize check box values by clicking another button 'done' in a gui. Below is my code so far:

3 vues (au cours des 30 derniers jours)
function [r1,r2,r3,r4,r5] = selectProcesses
bg = uibuttongroup('Visible','off',...
'Position',[0 0 1 1],...
'SelectionChangedFcn',@bselection);
% Create three radio buttons in the button group.
r1 = uicontrol(bg,'Style',...
'checkbox',...
'String','Write general outputs .csv of Drive Cycle',...
'Position',[10 350 500 30],...
'HandleVisibility','off');
r2 = uicontrol(bg,'Style','checkbox',...
'String','Write .csv of Avg Batt Power vs Avg Fuel Economy',...
'Position',[10 250 500 30],...
'HandleVisibility','off');
r3 = uicontrol(bg,'Style','checkbox',...
'String','Run 0-60 mph Test and write .csv',...
'Position',[10 150 500 30],...
'HandleVisibility','off');
r4 = uicontrol(bg,'Style','checkbox',...
'String','Run 50-70 mph Test and write .csv',...
'Position',[300 350 500 30],...
'HandleVisibility','off');
r5 = uicontrol(bg,'Style','checkbox',...
'String','Run 7% Grade Test and write .csv',...
'Position',[300 250 500 30],...
'HandleVisibility','off');
% Make the uibuttongroup visible after creating child objects.
bg.Visible = 'on';
function bselection(source,event)
display(['Previous: ' event.OldValue.String]);
display(['Current: ' event.NewValue.String]);
display('------------------');
end
end
  3 commentaires
Alok Nimrani
Alok Nimrani le 22 Fév 2019
"How do I initialize check box values by clicking another button 'done' in a gui"
Do you mean ticking the check boxes when you click on 'done' button in the above query? In that case, you can create a callback function for the 'done' button and inside that you can change the values of the checkboxes by setting the 'Value' property of the corresponding checkboxes appropriately.
Otherwise if your use-case is to have some checkboxes ticked at initialization, you can set the 'Selected' property to 'on'.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB Code Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by