0
Problem creating a checkbox uicontrol

the following code creates an array of checkboxes, labels and edit boxes in a frame inside a figure. The frame handle is stored in the structure field lsqfrm.fh. Tthe checkboxes are not grouped. If I comment out the code to create the checkbox the rest of the code runs ok. I have tried supplying the frame handle as the first parameter to the uicontrol as well as specifyning it explicitly as the parent as shown. When I use the handle as the first entry I get the error message "uicontrol: Wrong type for input argument #1: String expected". If I use the form shown below the error message is "uicontrol: Wrong type for input argument #1: A 'Figure' or a 'Frame uicontrol' handle expected." I have paused the code before creating the checkbox and checked the validity of the frame handle and its parent figure handle. Anyone have any ideas?

for i=1:size(paramarray,2)
    //checkbox
    uicontrol("parent",lsqfrm.fh...
        ,"Style","checkbutton"...
        ,"position",[lsqfrm.labx,lsqfrm.guih1,lsqfrm.bw,lsqfrm.bh]...
        ,"Callback_Type",2...
        ,"Callback","SelectParam("+string(i)+")"...
        ,"Max",1,"Min",0,"Value",0,...
        ,"BackgroundColor",[0.3,0.3,0.3]...
        ,"ForegroundColor",[1,1,1]...
        ,"Tag",tagarray(i)+"_chk"...
        ,"TooltipString","Check to include "+paramarray(i)+" in the LSQ fit");
    //checkbox label


Scilab 09-09-21, 5:17 p.m. DaveC49
0

I can create checkboxes elsewhere in a different part of my code. The only difference here is that the code is in a function and within a for loop in that function. Has me confused. Scilab6.1.1 on Linux Mint 20.

10-09-21, 6:15 a.m. DaveC49

Finally solved the problem . Seems to be associated with breaking the code out onto separate lines using "..." to indicate a new line. This worked OK for most other controls but not the checkbox. Will check it out further and put a bug report in when I can make it consistent.


11-09-21, 6:55 a.m. DaveC49

Login to add comment


0
You actually need just one callback for the checkboxes. Since you are creating your GUI "programmatically" (that is not with GUIDE) you can modify your code as follows: change the code for the creation of the axes as follows
handles.axes=axes('Units', 'Pixels','tag','axes_tag','Position',[25 25 N-200 M-50]);
that is define the property tag, you will use it in the checkbox callaback; the tag of a uicontrol might be used with the function findobj to access to that uicontrol change the defionition of the checkbox as follows
   handles.check{ii}=uicontrol('style','checkbox','string', ...
      ['Display_file_' num2str(ii)],'tag',['c_b_' num2str(ii)], ...
      'position',[N-150 M/2-ii*20 100 25],'callback','plot_sel_cb(handles.axes)');
15-09-21, 2:31 p.m. Armijo559

Thanks Will give it a try.


16-09-21, 2:40 a.m. DaveC49

Login to add comment


Log-in to answer to this question.