[Scilab-users] ?= GUI hel

Stefan Du Rietz sdr at durietz.se
Fri Nov 29 20:04:19 CET 2019


figure() is a much more versatile function for the creation of a figure; 
you can set all(?) properties at once.

scf() is useful when you want to change an existing figure.

Regards
Stefan


On 2019-11-29 19:35, Antoine Monmayrant wrote:
> Le Vendredi, Novembre 29, 2019 19:27 CET, Claus Futtrup <cfuttrup at gmail.com> a écrit:
>   
>> Hi Antoine, et al - anybody feel free to chime in.
>>
>> I see the below example uses f=figure() ... instead of f=scf().
>>
>> What's the reason for this preference?
> 
> No particular reason, I just use either scf() or figure().
> I think figure() was introduced to ease the transition for Matlab users.
> I think they call the same macro with different default values.
> 
> Antoine
> 
>>
>>   From my side, the only difference I can see, is that figure() generates
>> a place for a GUI with a grey background (background = 33) ... whereas
>> when I call scf() the background is white (background =  -2). I see the
>> same list of handles, and all other are also initialized to the same values.
>>
>> Is there a difference, maybe an invisible one?
>>
>> Best regards,
>> Claus
>>
>> On 29.11.2019 18:34, Antoine Monmayrant wrote:
>>>>> 4) I will also look into this. My problem is the steep learning curve.
>>>>> If you look at the Scilab tutorials you have the good-old Openeering
>>>>> LHY_Tutorial - it's incredibly complicated and long. Is LHY_Tutorial
>>>>> using the Model-Viewer-Controller approach? - Maybe the
>>>>> Model-Viewer-Controller could be presented in a _simple_ tutorial - is
>>>>> it possible?
>>>> Hmm, that would be a good idea.
>>>> I'll see whether I can put something together.
>>>> The thing is, MVC approach looks rather silly and overengineered on a small example.
>>> I have not tried to follow a MWC approach, but here is my attempt at making a really simple GUI to just show the basics (see below).
>>> It take numbers from two different types of uicontrols (a slider and an edit) and display the sum in a text uicontrol.
>>> To keep things simple, I positioned and sized the uicontrols manually instead of using a gridbag.
>>> I also tried to use the fancy syntax for get() and set() that do not require calling findobj(), as suggested by Samuel.
>>>
>>> Hope it helps,
>>>
>>> Antoine
>>>
>>>
>>> f=figure();
>>>
>>> /* ---------------- 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");
>>>       //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
>>>
>>> _______________________________________________
>>> users mailing list
>>> users at lists.scilab.org
>>> http://lists.scilab.org/mailman/listinfo/users
>>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>>
> 
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
> 



More information about the users mailing list