How do I control the size of a checkbox in a programmatic GUI?

15 visualizzazioni (ultimi 30 giorni)
I have a programmatic GUI and I'm trying to change the size of my checkboxes, but I can't get it to change. I've tried changing fontsize, position height, etc, but haven't figured out the right combination. The stubborn checkboxes remain the same size regardless. Here is my code to create the checkboxes.
hf = figure;
pos = [0, 0.9, 0.2, 0.04];
PlotStr = {'A','B','C','D'};
N = length(PlotStr);
NextRow = 0.064;
dx = 0.3;
TextPos = pos + [0 0 0 0];
CheckPos = pos + [0.3 0 0 0];
for inx = 1:N
textpos = TextPos - inx*[0 NextRow 0 0];
Check1Pos = CheckPos - inx*[0 NextRow 0 0];
PlotText(inx) = uicontrol(hf,'Style','text','String',PlotStr{inx},'Units','normalized','Position',textpos);
Checkbox(inx) = uicontrol(hf,'Style','checkbox','Units','normalized','Position',Check1Pos);
end

Risposte (1)

Jan
Jan il 16 Mar 2017
Modificato: Jan il 16 Mar 2017
The box itself does not change its size, because this size is controlled by the operating system. The size concerns the area occupied by teh combination of teh box and teh text. See:
figure;
uicontrol('Style', 'checkbox', 'String', 'Box 1', ...
'BackgroundColor', [1,0.3,0.3], ...
'Position', [10, 10, 100, 20]);
uicontrol('Style', 'checkbox', 'String', 'Box 2', ...
'BackgroundColor', [1,0.3,0.3], ...
'Position', [10, 50, 200, 60]);

Categorie

Scopri di più su Software Development Tools 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