[Scilab-users] ?= GUI hel

Antoine Monmayrant antoine.monmayrant at laas.fr
Tue Dec 3 16:13:58 CET 2019


Le 03/12/2019 à 15:20, Stéphane Mottelet a écrit :
> Sorry Antoine but I have completely lost the thread. Please give us an 
> example of what (still) does not work for you.
Ah, sorry for the noise.
I don't know why your syntax was not working, but it clearly was not 
working.
I saw a bunch of java related issues on command line so I restarted 
scilab and boom, both syntax where working perfectly.
I have no idea what happened and how to reproduce it.

See below the example GUI I built using the new get/set syntax.

I think an example showing the full power of tagPath to distinguish two 
uicontrols with same tag but different parents (with different tags) 
could be useful too.


Antoine


//////////////////////////////////////////

f=figure();
f.tag="myfig";
/* ---------------- First number from slider ----------------  */
//values
nmin=-5;
nmax=10;
nini=7;
nsmallstep=1;
nsbigstep=2;
//slider position and size
x=10;
y=20;
w=100;
h=25;
//slider uicontrol creation in figure f
hslider=uicontrol(f, ...
     "style", "slider", ...
     "tag", "slider1", ...
     "backgroundcolor", [1 1 1], ...
     "position", [x y w h], ...
     "value", nini, ...
     "min", nmin, ...
     "max", nmax, ...
     "sliderstep", [nsmallstep, nsbigstep], ...
     "callback", "update_values");

/* ------------- Second number from an editable text -------------  */
// initial value
editini="3.14";
//edit position and size
x2=x;
y2=y+h+5;
w2=w;
h2=h;
//edit uicontrol creation in figure f
hedit=uicontrol(f, ...
     "style", "edit", ...
     "tag", "edit2", ...
     "backgroundcolor", [1 1 1], ...
     "position", [x2 y2 w2 h2], ...
     "string", editini, ...
     "callback", "update_values");

/* ------------- Sum displayed in a text uicontrol ------------- */
// initial value
textini="Nothing"
//edit position and size
x3=x+w+5;
y3=y;
w3=w;
h3=2*h+5;
//slider uicontrol creation
htext=uicontrol(f, ...
     "style", "text", ...
     "tag", "text3", ...
     "backgroundcolor", [1 1 1], ...
     "position", [x3 y3 w3 h3], ...
     "string", textini);

/* -------- callback function for slider and edit uicontrols --------  */
//Whenever user interacts with the slider or the edit uicontrols
//  show the sum of both numbers in the text field
function update_values()
     //temporarily deactivate the callback (don't want callback calls to 
stack up while processing the current one
     set(gcbo,"callback_type",-1);
     /*
       Using the unique tag chosen at the creation time of the uicontrols
       to set/get the uicontrol properties
     */
     //get both numbers from the slider and the edit uicontrols
     number1=get("slider1", "value");
     string2=get("edit2", "string");
     //alternative syntax using the full tagpath ie "tagOfParent/tag" to 
avoid confusion
//    number1=get("myfig/slider1", "value");
//    string2=get("myfig/edit2", "string");
     //do your maths & conversion
     string3=string(number1+evstr(string2));
     //change the string displayed in the text uicontrol
     set("text3", "string", string3);
     //reactivate callback
     set(gcbo,"callback_type",0);
endfunction

//////////////////////////////////////////

>
> S.
>
> Le 29/11/2019 à 12:28, Antoine Monmayrant a écrit :
>>> get() and set() can now use a tagsPath, that might be less ambiguate
>>> than using findobj(), that returns the first component with a matching
>>> tag (unless only unique tags are defined). The documentation of 
>>> set() is
>>> being overhauled 
>>> <https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/bugzilla.scilab.org/show_bug.cgi?id=15414>. 
>>> You
>>> may have a look to it there
>>> <https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/bugzilla.scilab.org/attachment.cgi?id=4997>. 
>>> The same work on
>>> the get()'s page is pending
>>> <https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/bugzilla.scilab.org/show_bug.cgi?id=15226>. 
>>>
>> I tried to use your syntax in a callback and it does not work.
>> The values returned are not the same than when using findobj and the 
>> old syntax (I always get the initial value for the uicontrol, not the 
>> updated ones).
>> I'll try to get a minimal working example...
>>
>> Antoine
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users 
>>
>



More information about the users mailing list