Checkboxes disappear when a new one created (matlab 2007b)
Mostra commenti meno recenti
Hello,
I have a button group with handle handles.dataSelect and I'm trying to add some texts and checkboxes to that group based on information contained in handles.dataStruct. I would expect the output to be something like
Channel Select
[] Channel 1
[] Channel 2
etc...
Temperature Select
[] T = 20 K
[] T = 40 K
etc...
However, what I see instead is
Channel Select
... lots of space ...
[] Last channel
Temperature Select
... lots of space ...
[] Last temperature
I checked and the button group does have all of the checkboxes as children and all children ARE in fact set to be visible and enabled.
However, I don't see any but the last channel and the last temperature. When I debugged, with every for loop iteration the previous checkbox disappeared from view while the new checkbox was added...
It seems like some simple mistake on my part, but I can't quite figure out what exactly I did wrong. Any help would be appreciated, the exact code I used is below.
Thank you,
Ilya
function createView( handles )
chPos=0.75;
handles.hText1=uicontrol(handles.dataSelect,'Style','text',...
'Tag','ChSelectText','String','Channel Select','Units','normalized',...
'HorizontalAlignment','left','Position',[0.1, chPos, 0.6, .2]);
for j=1:length(handles.dataStruct.channels),
handles.hChannelBox(j)=uicontrol(handles.dataSelect,...
'Style','checkbox','Tag',['Ch' num2str(j) 'box'],'String',...
['Channel ' num2str(handles.dataStruct.channels(j))],...
'Units','normalized','HorizontalAlignment','left',...
'Position',[0.1, chPos-j*0.06, 0.6, .2]);
end
tempPos=chPos-length(handles.dataStruct.channels)*0.06-0.2;
handles.hText2=uicontrol(handles.dataSelect,'Style','text',...
'Tag','TempSelectText','String','Temperature Select',...
'Units','normalized','HorizontalAlignment','left','Position',...
[0.1, tempPos, 0.6, .2]);
for j=1:length(handles.dataStruct.temps),
handles.hTempBox(j)=uicontrol(handles.dataSelect,...
'Style','checkbox','Tag',['Temp' num2str(j) 'box'],'String',...
['T = ' num2str(handles.dataStruct.temps(j)) ' K'],...
'Units','normalized','HorizontalAlignment','left',...
'Position',[0.1, tempPos-j*0.06, 0.6, .2]);
end
guidata(handles.dataSelect, handles);
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Scripts in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!