Re: [Scilab-users] ?= GUI hel

2019-12-03 Thread Antoine Monmayrant


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 
. 
You

may have a look to it there
. 
The same work on

the get()'s page is pending
. 


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@lists.scilab.org
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users 




___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-12-03 Thread Stéphane Mottelet
Sorry Antoine but I have completely lost the thread. Please give us an 
example of what (still) does not work for you.


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 
.
 You
may have a look to it there
.
 The same work on
the get()'s page is pending
.

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@lists.scilab.org
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users


--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-12-03 Thread Antoine Monmayrant


Le 03/12/2019 à 13:14, P M a écrit :


> So why do they use "clear" at the beginning of every script?
This is like a Matlab signature.


I am no matlabber, but like to start my scripts with:

clc()
clear("all")
delete("all")
// in older days also: stacksize("max")

At least so long, as I am working on a script.
Pressing F5 for restating the script just ensures, that I always start 
from new without the danger of keeping old variables/figure etc


You forgot the

xdel(winsid())

to get rid of all the opened windows...

;-)



Maybe this is some kind of lazyness...I would say: convenience :-)

cheers.




___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-12-03 Thread P M
> > So why do they use "clear" at the beginning of every script? This is
> like a Matlab signature.
>

I am no matlabber, but like to start my scripts with:

clc()
clear("all")
delete("all")
// in older days also: stacksize("max")

At least so long, as I am working on a script.
Pressing F5 for restating the script just ensures, that I always start from
new without the danger of keeping old variables/figure etc

Maybe this is some kind of lazyness...I would say: convenience :-)

cheers.
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-12-03 Thread Stéphane Mottelet


Le 30/11/2019 à 11:30, Samuel Gougeon a écrit :

Le 29/11/2019 à 21:53, Stéphane Mottelet a écrit :

Le 29/11/2019 à 21:21, Claus Futtrup a écrit :


Hi Stéphane

Lazy = not pretty.


Matlab users do not have this possibility, and as a result, programs 
do not suffer from eventual border effects. 


So why do they use "clear" at the beginning of every script? This is 
like a Matlab signature.

In Scilab, i never use clear (all), and it works.
Neither do I. But I see the same behavior in Scilab programs of users 
around me and very often in Scilab programs posted by users in the ML, 
and precisely due to the potential border effect of lazy global 
variables. The sydrom is:


"I don't understand why my program worked before I quit and relaunched 
Scilab ?"


Concerning this habit of Matlab users, I have a different theory : until 
recently, it was tedious to use functions in order to give a decent 
structure to Matlab programs because each function had to reside in one 
single .m file. Then may users took the habit to write very long scripts 
hence with variables living in the main workspace. Then a "clear" at the 
begining of this kind of script was at least prophylatic, not to say a 
must !




But I know many Matlab users using a bunch of "global" statements. 
This is WORSE than lazy globals...


Agreed, and IMO less handy.

Samuel



___
users mailing list
users@lists.scilab.org
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users 



--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-30 Thread Samuel Gougeon

Le 29/11/2019 à 21:53, Stéphane Mottelet a écrit :

Le 29/11/2019 à 21:21, Claus Futtrup a écrit :


Hi Stéphane

Lazy = not pretty.


Matlab users do not have this possibility, and as a result, programs 
do not suffer from eventual border effects. 


So why do they use "clear" at the beginning of every script? This is 
like a Matlab signature.

In Scilab, i never use clear (all), and it works.

But I know many Matlab users using a bunch of "global" statements. 
This is WORSE than lazy globals...


Agreed, and IMO less handy.

Samuel



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-29 Thread Stéphane Mottelet

Le 29/11/2019 à 21:21, Claus Futtrup a écrit :


Hi Stéphane

Lazy = not pretty.


Matlab users do not have this possibility, and as a result, programs do 
not suffer from eventual border effects. But I know many Matlab users 
using a bunch of "global" statements. This is WORSE than lazy globals...


However, you don't need to use this mechanism in your GUI. You have gcbo 
+ proper backtracking on the parents, or (better) you can use  tags and 
findobj.


S.



... but you didn't answer my question. Which way do you personally 
prefer? ... and why?


Cheers,
Claus

(...)


--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-29 Thread Claus Futtrup

Hi Stéphane

Lazy = not pretty.

... but you didn't answer my question. Which way do you personally 
prefer? ... and why?


Cheers,
Claus

On 29.11.2019 21:13, Stéphane Mottelet wrote:

Hello again,


Le 29 nov. 2019 à 19:55, Claus Futtrup  a écrit :


Hi Stéphane

>In "ge_fs=ge_fs" the lhs is a local copy and the rhs the variable in 
the calling context.


I figured something like this was going on, but I don't find it 
logical. I read this as follows: The ge_r is a global handle, for 
which the function doesn't have write access. When you assign it to a 
local variable (it can be the same name, or a new name, I suppose), 
then suddenly this opens up for writing to it (so you can set the 
properties). Strange. I don't think even a hardcore programmer can 
find this to be "pretty code" ... it looks like a hack / a workaround 
to me.




No hack here. Please 
see https://wiki.scilab.org/howto/global%20and%20local%20variables 



Even the very orthodoxic Julia uses in some similar context  lazy 
global variables.


S.


I read your response just as - this is another way to do it - but 
which way do you personally prefer? ... and why? (maybe execution 
speed? ... or is there a benefit in flexibility that I cannot see?).


Best regards,
Claus

On 29.11.2019 19:21, Stéphane Mottelet wrote:



Le 29/11/2019 à 19:17, Claus Futtrup a écrit :

Hi Stéphane

Hm, you're right. This actually fixes the problem, but I do find it 
to be a strange "solution" that you write each of them to be equal 
with itself ... I prefer calling the set() function.


In "ge_fs=ge_fs" the lhs is a local copy and the rhs the variable in 
the calling context.




Cheers,
Claus

On 29.11.2019 19:05, Stéphane Mottelet wrote:

To makeit work, just insert

ge_r=ge_r;
ge_fs=ge_fs;
ge_hz=ge_hz;

at the begining of function calc.

My two cents...

S.


Le 29/11/2019 à 18:58, Claus Futtrup a écrit :

Hi Antoine

>Not much progress because I never managed to get a minimal working example
I can repeat my example again and again. It never works. Please 
see it below.


Do you agree. This consistently fails if you run it from Scinotes 
editor ... but if I copy e.g. ge_r.visible = "on" to the command 
line (not from within the calc function), then it shows up.


/Claus

// BAD_GUI_EXAMPLE.SCE
//
// Demo of how _NOT_ to build a simple GUI in Scilab.

// Initialize variables
m  =  1;  // Moving mass 'm'(kilogram)
k  =  1;  // Stiffness, spring constant 'k'(Newton per meter)
fres  =  1;  // Resonance frequency (Hertz)

function  calc()
 m  =  evstr(get(ge_m,"string"));  // get content in uicontrol ge_m
 k  =  evstr(get(ge_k,"string"));  // get content in uicontrol ge_k
 fres=sqrt(k/m)/(2*%pi);
 // putting GUI updates inside the calculation routine is not 
pretty code.

 ge_r.visible  =  "on";
 ge_fs.visible  =  "on";// THIS DOESN'T WORK
 ge_hz.visible  =  "on";
// set(ge_r,"Visible","on"); // THIS WORKS
// set(ge_fs,"Visible","on");
// set(ge_hz,"Visible","on");
 // update global variables
 [m,k,fres]=return(m,k,fres);
endfunction

function  goodbye()
 close(ge);  // Close GUI window
 printf("Resulting fres: %f Hertz\n",fres);
 abort  // Print result in console (e.g. for copy/paste), then kill the app
endfunction

ge  =  scf();  // GUI Example, Initialize and 'set current figure'
as  =  ge.axes_size;  // read size of window, as = [width height]
ge.figure_name  =  "GUI Example";  // Change window header

uicontrol("style","text","string","Moving mass :","position",  ..
   [10  as(2)-35  80  20],"background",[1  1  1]);  // white background
   // position properties has four parameters = x,y,width,height
   // y-position counts from lower left corner, so we subtract from 'as'
ge_m  =  uicontrol("style","edit","string",string(m),  ..
   "position",[100  as(2)-35  80  20]);
uicontrol("style","text","string","kg ","position",  ..
   [200  as(2)-35  30  20],"background",[1  1  1]);

uicontrol("style","text","string","Stiffness :","position",  ..
   [10  as(2)-60  80  20],"background",[1  1  1]);
ge_k  =  uicontrol("style","edit","string",string(k),  ..
   "position",[100  as(2)-60  80  20]);
uicontrol("style","text","string","N/m ","position",  ..
   [200  as(2)-60  30  20],"background",[1  1  1]);

uicontrol("style","pushbutton","string","Calculate",  ..
   "position",[10  as(2)-85  80  20],"callback","calc");

ge_r  =  uicontrol("style","text","string","Result :","position",  ..
   [10  as(2)-110  80  20],"visible","off");  // keep these hidden for 
a start
ge_fs  =  uicontrol("style","text","string",string(fres),  ..
   "position",[100  as(2)-110  80  20],"visible","off");
ge_hz  =  uicontrol("style","text","string","Hz ","position",  ..
   [200  as(2)-110  30  20],"visible","off");

uicontrol("style","pushbutton","string","Exit",  ..
  

Re: [Scilab-users] ?= GUI hel

2019-11-29 Thread Stéphane Mottelet
Hello again,

> Le 29 nov. 2019 à 19:55, Claus Futtrup  a écrit :
> 
> 
> Hi Stéphane
> 
> >In "ge_fs=ge_fs" the lhs is a local copy and the rhs the variable in the 
> >calling context.
> 
> I figured something like this was going on, but I don't find it logical. I 
> read this as follows: The ge_r is a global handle, for which the function 
> doesn't have write access. When you assign it to a local variable (it can be 
> the same name, or a new name, I suppose), then suddenly this opens up for 
> writing to it (so you can set the properties). Strange. I don't think even a 
> hardcore programmer can find this to be "pretty code" ... it looks like a 
> hack / a workaround to me.
> 

No hack here. Please see 
https://wiki.scilab.org/howto/global%20and%20local%20variables

Even the very orthodoxic Julia uses in some similar context  lazy global 
variables.

S.


> I read your response just as - this is another way to do it - but which way 
> do you personally prefer? ... and why? (maybe execution speed? ... or is 
> there a benefit in flexibility that I cannot see?).
> 
> Best regards,
> Claus
> 
> On 29.11.2019 19:21, Stéphane Mottelet wrote:
>> 
>> Le 29/11/2019 à 19:17, Claus Futtrup a écrit :
>>> Hi Stéphane
>>> 
>>> Hm, you're right. This actually fixes the problem, but I do find it to be a 
>>> strange "solution" that you write each of them to be equal with itself ... 
>>> I prefer calling the set() function.
>> In "ge_fs=ge_fs" the lhs is a local copy and the rhs the variable in the 
>> calling context.
>> 
>>> 
>>> Cheers,
>>> Claus
>>> 
>>> On 29.11.2019 19:05, Stéphane Mottelet wrote:
 To makeit work, just insert
 
 ge_r=ge_r;
 ge_fs=ge_fs;
 ge_hz=ge_hz;
 at the begining of function calc.
 
 My two cents...
 S.
 
 
 
 Le 29/11/2019 à 18:58, Claus Futtrup a écrit :
> Hi Antoine
> 
> >Not much progress because I never managed to get a minimal working 
> >example
> I can repeat my example again and again. It never works. Please see it 
> below.
> 
> Do you agree. This consistently fails if you run it from Scinotes editor 
> ... but if I copy e.g. ge_r.visible = "on" to the command line (not from 
> within the calc function), then it shows up.
> 
> /Claus
> 
> // BAD_GUI_EXAMPLE.SCE
> //
> // Demo of how _NOT_ to build a simple GUI in Scilab.
> 
> // Initialize variables
> m = 1; // Moving mass 'm' (kilogram)
> k = 1; // Stiffness, spring constant 'k' (Newton per meter)
> fres = 1; // Resonance frequency (Hertz)
> 
> function calc()
> m = evstr(get(ge_m,"string")); // get content in uicontrol ge_m
> k = evstr(get(ge_k,"string")); // get content in uicontrol ge_k
> fres=sqrt(k/m)/(2*%pi);
> // putting GUI updates inside the calculation routine is not pretty 
> code.
> ge_r.visible = "on";
> ge_fs.visible = "on";   // THIS DOESN'T WORK
> ge_hz.visible = "on";
> //set(ge_r,"Visible","on"); // THIS WORKS
> //set(ge_fs,"Visible","on");
> //set(ge_hz,"Visible","on");
> // update global variables
> [m,k,fres]=return(m,k,fres);
> endfunction
> 
> function goodbye()
> close(ge); // Close GUI window
> printf("Resulting fres: %f Hertz\n",fres);
> abort // Print result in console (e.g. for copy/paste), then kill the 
> app
> endfunction
> 
> ge = scf(); // GUI Example, Initialize and 'set current figure'
> as = ge.axes_size; // read size of window, as = [width height]
> ge.figure_name = "GUI Example"; // Change window header
> 
> uicontrol("style","text","string","Moving mass :","position", ..
>   [10 as(2)-35 80 20],"background",[1 1 1]); // white background
>   // position properties has four parameters = x,y,width,height
>   // y-position counts from lower left corner, so we subtract 
> from 'as'
> ge_m = uicontrol("style","edit","string",string(m), ..
>   "position",[100 as(2)-35 80 20]);
> uicontrol("style","text","string"," kg ","position", ..
>   [200 as(2)-35 30 20],"background",[1 1 1]);
> 
> uicontrol("style","text","string","Stiffness   :","position", ..
>   [10 as(2)-60 80 20],"background",[1 1 1]);
> ge_k = uicontrol("style","edit","string",string(k), ..
>   "position",[100 as(2)-60 80 20]);
> uicontrol("style","text","string"," N/m ","position", ..
>   [200 as(2)-60 30 20],"background",[1 1 1]);
> 
> uicontrol("style","pushbutton","string","Calculate", ..
>   "position",[10 as(2)-85 80 20],"callback","calc");
> 
> ge_r = uicontrol("style","text","string","Result :","position", ..
>   [10 as(2)-110 80 20],"visible","off"); // keep these hidden for 
> a start
> ge_fs = uicontrol("style","text","string",string(fres), ..

Re: [Scilab-users] ?= GUI hel

2019-11-29 Thread Claus Futtrup

Hi Stéphane

>In "ge_fs=ge_fs" the lhs is a local copy and the rhs the variable in 
the calling context.


I figured something like this was going on, but I don't find it logical. 
I read this as follows: The ge_r is a global handle, for which the 
function doesn't have write access. When you assign it to a local 
variable (it can be the same name, or a new name, I suppose), then 
suddenly this opens up for writing to it (so you can set the 
properties). Strange. I don't think even a hardcore programmer can find 
this to be "pretty code" ... it looks like a hack / a workaround to me.


I read your response just as - this is another way to do it - but which 
way do you personally prefer? ... and why? (maybe execution speed? ... 
or is there a benefit in flexibility that I cannot see?).


Best regards,
Claus

On 29.11.2019 19:21, Stéphane Mottelet wrote:



Le 29/11/2019 à 19:17, Claus Futtrup a écrit :

Hi Stéphane

Hm, you're right. This actually fixes the problem, but I do find it 
to be a strange "solution" that you write each of them to be equal 
with itself ... I prefer calling the set() function.


In "ge_fs=ge_fs" the lhs is a local copy and the rhs the variable in 
the calling context.




Cheers,
Claus

On 29.11.2019 19:05, Stéphane Mottelet wrote:

To makeit work, just insert

ge_r=ge_r;
ge_fs=ge_fs;
ge_hz=ge_hz;

at the begining of function calc.

My two cents...

S.


Le 29/11/2019 à 18:58, Claus Futtrup a écrit :

Hi Antoine

>Not much progress because I never managed to get a minimal working example
I can repeat my example again and again. It never works. Please see 
it below.


Do you agree. This consistently fails if you run it from Scinotes 
editor ... but if I copy e.g. ge_r.visible = "on" to the command 
line (not from within the calc function), then it shows up.


/Claus

// BAD_GUI_EXAMPLE.SCE
//
// Demo of how _NOT_ to build a simple GUI in Scilab.

// Initialize variables
m  =  1;  // Moving mass 'm'(kilogram)
k  =  1;  // Stiffness, spring constant 'k'(Newton per meter)
fres  =  1;  // Resonance frequency (Hertz)

function  calc()
 m  =  evstr(get(ge_m,"string"));  // get content in uicontrol ge_m
 k  =  evstr(get(ge_k,"string"));  // get content in uicontrol ge_k
 fres=sqrt(k/m)/(2*%pi);
 // putting GUI updates inside the calculation routine is not pretty 
code.

 ge_r.visible  =  "on";
 ge_fs.visible  =  "on";// THIS DOESN'T WORK
 ge_hz.visible  =  "on";
// set(ge_r,"Visible","on"); // THIS WORKS
// set(ge_fs,"Visible","on");
// set(ge_hz,"Visible","on");
 // update global variables
 [m,k,fres]=return(m,k,fres);
endfunction

function  goodbye()
 close(ge);  // Close GUI window
 printf("Resulting fres: %f Hertz\n",fres);
 abort  // Print result in console (e.g. for copy/paste), then kill the app
endfunction

ge  =  scf();  // GUI Example, Initialize and 'set current figure'
as  =  ge.axes_size;  // read size of window, as = [width height]
ge.figure_name  =  "GUI Example";  // Change window header

uicontrol("style","text","string","Moving mass :","position",  ..
   [10  as(2)-35  80  20],"background",[1  1  1]);  // white background
   // position properties has four parameters = x,y,width,height
   // y-position counts from lower left corner, so we subtract from 'as'
ge_m  =  uicontrol("style","edit","string",string(m),  ..
   "position",[100  as(2)-35  80  20]);
uicontrol("style","text","string","kg ","position",  ..
   [200  as(2)-35  30  20],"background",[1  1  1]);

uicontrol("style","text","string","Stiffness :","position",  ..
   [10  as(2)-60  80  20],"background",[1  1  1]);
ge_k  =  uicontrol("style","edit","string",string(k),  ..
   "position",[100  as(2)-60  80  20]);
uicontrol("style","text","string","N/m ","position",  ..
   [200  as(2)-60  30  20],"background",[1  1  1]);

uicontrol("style","pushbutton","string","Calculate",  ..
   "position",[10  as(2)-85  80  20],"callback","calc");

ge_r  =  uicontrol("style","text","string","Result :","position",  ..
   [10  as(2)-110  80  20],"visible","off");  // keep these hidden for 
a start
ge_fs  =  uicontrol("style","text","string",string(fres),  ..
   "position",[100  as(2)-110  80  20],"visible","off");
ge_hz  =  uicontrol("style","text","string","Hz ","position",  ..
   [200  as(2)-110  30  20],"visible","off");

uicontrol("style","pushbutton","string","Exit",  ..
   "position",[10  as(2)-135  80  20],"callback","goodbye");

On 29.11.2019 10:20, Antoine Monmayrant wrote:

Le Jeudi, Novembre 28, 2019 19:40 CET, Claus Futtrup  a 
écrit:
  

Hi Antoine

Also, you should better use get(a, 'propertyName') or set(a, 'propertyName', 
value) instead of a.propertyName and a.propertyName=value in your callbacks.


I see what you mean. I just now had trouble turning visibility on/off,
but using set(), it works fine. Thanks for the tip.

It's something quite weird, maybe a 

Re: [Scilab-users] ?= GUI hel

2019-11-29 Thread Claus Futtrup

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?

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@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-29 Thread Claus Futtrup

Hi Antoine

Thank you, with just 82 lines (incl. comments) it's within reason and 
I'm thinking it could be a suitable example for Scilab documentation. I 
shall study the details and see how it works out in my application (that 
I'm doing for work).


Cheers,
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@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-29 Thread Stéphane Mottelet

To makeit work, just insert

ge_r=ge_r;
ge_fs=ge_fs;
ge_hz=ge_hz;

at the begining of function calc.

My two cents...

S.


Le 29/11/2019 à 18:58, Claus Futtrup a écrit :

Hi Antoine

>Not much progress because I never managed to get a minimal working example
I can repeat my example again and again. It never works. Please see it 
below.


Do you agree. This consistently fails if you run it from Scinotes 
editor ... but if I copy e.g. ge_r.visible = "on" to the command line 
(not from within the calc function), then it shows up.


/Claus

// BAD_GUI_EXAMPLE.SCE
//
// Demo of how _NOT_ to build a simple GUI in Scilab.

// Initialize variables
m  =  1;  // Moving mass 'm'(kilogram)
k  =  1;  // Stiffness, spring constant 'k'(Newton per meter)
fres  =  1;  // Resonance frequency (Hertz)

function  calc()
 m  =  evstr(get(ge_m,"string"));  // get content in uicontrol ge_m
 k  =  evstr(get(ge_k,"string"));  // get content in uicontrol ge_k
 fres=sqrt(k/m)/(2*%pi);
 // putting GUI updates inside the calculation routine is not pretty code.
 ge_r.visible  =  "on";
 ge_fs.visible  =  "on";// THIS DOESN'T WORK
 ge_hz.visible  =  "on";
// set(ge_r,"Visible","on"); // THIS WORKS
// set(ge_fs,"Visible","on");
// set(ge_hz,"Visible","on");
 // update global variables
 [m,k,fres]=return(m,k,fres);
endfunction

function  goodbye()
 close(ge);  // Close GUI window
 printf("Resulting fres: %f Hertz\n",fres);
 abort  // Print result in console (e.g. for copy/paste), then kill the app
endfunction

ge  =  scf();  // GUI Example, Initialize and 'set current figure'
as  =  ge.axes_size;  // read size of window, as = [width height]
ge.figure_name  =  "GUI Example";  // Change window header

uicontrol("style","text","string","Moving mass :","position",  ..
   [10  as(2)-35  80  20],"background",[1  1  1]);  // white background
   // position properties has four parameters = x,y,width,height
   // y-position counts from lower left corner, so we subtract from 'as'
ge_m  =  uicontrol("style","edit","string",string(m),  ..
   "position",[100  as(2)-35  80  20]);
uicontrol("style","text","string","kg ","position",  ..
   [200  as(2)-35  30  20],"background",[1  1  1]);

uicontrol("style","text","string","Stiffness :","position",  ..
   [10  as(2)-60  80  20],"background",[1  1  1]);
ge_k  =  uicontrol("style","edit","string",string(k),  ..
   "position",[100  as(2)-60  80  20]);
uicontrol("style","text","string","N/m ","position",  ..
   [200  as(2)-60  30  20],"background",[1  1  1]);

uicontrol("style","pushbutton","string","Calculate",  ..
   "position",[10  as(2)-85  80  20],"callback","calc");

ge_r  =  uicontrol("style","text","string","Result :","position",  ..
   [10  as(2)-110  80  20],"visible","off");  // keep these hidden for 
a start
ge_fs  =  uicontrol("style","text","string",string(fres),  ..
   "position",[100  as(2)-110  80  20],"visible","off");
ge_hz  =  uicontrol("style","text","string","Hz ","position",  ..
   [200  as(2)-110  30  20],"visible","off");

uicontrol("style","pushbutton","string","Exit",  ..
   "position",[10  as(2)-135  80  20],"callback","goodbye");

On 29.11.2019 10:20, Antoine Monmayrant wrote:

Le Jeudi, Novembre 28, 2019 19:40 CET, Claus Futtrup  a 
écrit:
  

Hi Antoine

Also, you should better use get(a, 'propertyName') or set(a, 'propertyName', 
value) instead of a.propertyName and a.propertyName=value in your callbacks.


I see what you mean. I just now had trouble turning visibility on/off,
but using set(), it works fine. Thanks for the tip.

It's something quite weird, maybe a race condition.
I've seen it when using 'a.prop' or 'a.prop=value' syntax in either a callback 
function or in a for loop.
When you repeatedly use this syntax, scilab tends to forget that 'a' exists and 
that it's a handle with different properties.
The initial bug report is here:http://bugzilla.scilab.org/show_bug.cgi?id=15786
Not much progress because I never managed to get a minimal working example 
(it's an Heisenbug).

Antoine


Best regards,
Claus

On 28.11.2019 17:47, Antoine Monmayrant wrote:

Le Jeudi, Novembre 28, 2019 17:05 CET, Claus Futtrup  a 
écrit:
   

Hi Antoine, et al.

Your reply is very helpful, so I think you got the right question :-)

1) Good point that I can use callback on every uicontrol. This would be
suitable for a simple example (like gui_example.sce) ... but for heavy
calculations, it might be more practical with a CALC button. P.S. The
correct equation for the resonance frequency is fres=sqrt(k/m)/(2*%pi);

You are right.
Also, the trick to disable the callback function/ reenable it is key for 
sliders that tend to generate an avalanche of call to the function when one 
moves the cursor.


2) I see what you mean, so not having an empty space, but "show" the
whole she-bang from the beginning. I didn't want to do that (just

Re: [Scilab-users] ?= GUI hel

2019-11-29 Thread Claus Futtrup

Hi Antoine


Not much progress because I never managed to get a minimal working example


I can repeat my example again and again. It never works. Please see it 
below.


Do you agree. This consistently fails if you run it from Scinotes editor 
... but if I copy e.g. ge_r.visible = "on" to the command line (not from 
within the calc function), then it shows up.


/Claus

// BAD_GUI_EXAMPLE.SCE
//
// Demo of how _NOT_ to build a simple GUI in Scilab.

// Initialize variables
m  =  1;  // Moving mass 'm'(kilogram)
k  =  1;  // Stiffness, spring constant 'k'(Newton per meter)
fres  =  1;  // Resonance frequency (Hertz)

function  calc()
m  =  evstr(get(ge_m,"string"));  // get content in uicontrol ge_m
k  =  evstr(get(ge_k,"string"));  // get content in uicontrol ge_k
fres=sqrt(k/m)/(2*%pi);
// putting GUI updates inside the calculation routine is not pretty code.
ge_r.visible  =  "on";
ge_fs.visible  =  "on";// THIS DOESN'T WORK
ge_hz.visible  =  "on";
// set(ge_r,"Visible","on"); // THIS WORKS
// set(ge_fs,"Visible","on");
// set(ge_hz,"Visible","on");
// update global variables
[m,k,fres]=return(m,k,fres);
endfunction

function  goodbye()
close(ge);  // Close GUI window
printf("Resulting fres: %f Hertz\n",fres);
abort  // Print result in console (e.g. for copy/paste), then kill the app
endfunction

ge  =  scf();  // GUI Example, Initialize and 'set current figure'
as  =  ge.axes_size;  // read size of window, as = [width height]
ge.figure_name  =  "GUI Example";  // Change window header

uicontrol("style","text","string","Moving mass :","position",  ..
  [10  as(2)-35  80  20],"background",[1  1  1]);  // white background
  // position properties has four parameters = x,y,width,height
  // y-position counts from lower left corner, so we subtract from 'as'
ge_m  =  uicontrol("style","edit","string",string(m),  ..
  "position",[100  as(2)-35  80  20]);
uicontrol("style","text","string","kg ","position",  ..
  [200  as(2)-35  30  20],"background",[1  1  1]);

uicontrol("style","text","string","Stiffness :","position",  ..
  [10  as(2)-60  80  20],"background",[1  1  1]);
ge_k  =  uicontrol("style","edit","string",string(k),  ..
  "position",[100  as(2)-60  80  20]);
uicontrol("style","text","string","N/m ","position",  ..
  [200  as(2)-60  30  20],"background",[1  1  1]);

uicontrol("style","pushbutton","string","Calculate",  ..
  "position",[10  as(2)-85  80  20],"callback","calc");

ge_r  =  uicontrol("style","text","string","Result :","position",  ..
  [10  as(2)-110  80  20],"visible","off");  // keep these hidden for a 
start
ge_fs  =  uicontrol("style","text","string",string(fres),  ..
  "position",[100  as(2)-110  80  20],"visible","off");
ge_hz  =  uicontrol("style","text","string","Hz ","position",  ..
  [200  as(2)-110  30  20],"visible","off");

uicontrol("style","pushbutton","string","Exit",  ..
  "position",[10  as(2)-135  80  20],"callback","goodbye");


On 29.11.2019 10:20, Antoine Monmayrant wrote:

Le Jeudi, Novembre 28, 2019 19:40 CET, Claus Futtrup  a 
écrit:
  

Hi Antoine

Also, you should better use get(a, 'propertyName') or set(a, 'propertyName', 
value) instead of a.propertyName and a.propertyName=value in your callbacks.


I see what you mean. I just now had trouble turning visibility on/off,
but using set(), it works fine. Thanks for the tip.

It's something quite weird, maybe a race condition.
I've seen it when using 'a.prop' or 'a.prop=value' syntax in either a callback 
function or in a for loop.
When you repeatedly use this syntax, scilab tends to forget that 'a' exists and 
that it's a handle with different properties.
The initial bug report is here: http://bugzilla.scilab.org/show_bug.cgi?id=15786
Not much progress because I never managed to get a minimal working example 
(it's an Heisenbug).

Antoine


Best regards,
Claus

On 28.11.2019 17:47, Antoine Monmayrant wrote:

Le Jeudi, Novembre 28, 2019 17:05 CET, Claus Futtrup  a 
écrit:
   

Hi Antoine, et al.

Your reply is very helpful, so I think you got the right question :-)

1) Good point that I can use callback on every uicontrol. This would be
suitable for a simple example (like gui_example.sce) ... but for heavy
calculations, it might be more practical with a CALC button. P.S. The
correct equation for the resonance frequency is fres=sqrt(k/m)/(2*%pi);

You are right.
Also, the trick to disable the callback function/ reenable it is key for 
sliders that tend to generate an avalanche of call to the function when one 
moves the cursor.


2) I see what you mean, so not having an empty space, but "show" the
whole she-bang from the beginning. I didn't want to do that (just
deleting the IF-statement), but it could be the best solution in the end
(rather than the inline GUI updates), if nothing better shows up. This
was somehow the "core" of my question. Maybe I ask for 

Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Stefan Du Rietz


On 2019-11-28 20:55, Samuel Gougeon wrote:

Le 28/11/2019 à 17:47, Antoine Monmayrant a écrit :

.../...
Also, you should better use get(a, 'propertyName') or set(a, 
'propertyName', value) instead of a.propertyName and 
a.propertyName=value in your callbacks.
I have found that this latter syntax is causing a lot of bug if your 
callback get called really often. I still don't know why.



OK. Now i remember, indeed, that some handle.prop access are badly 
parsed as reading or defining a structure instead of reading or setting 
the (expectedly) defined handle...




I have also noticed all that.

But at last I managed to get it working. ;-)

I had to
1. copy the structure from user_data
2. edit the copied structure
3. set user_data to the edited structure


To Samuel 20:35:

My GUI data.are handles exept a few things I update simultaneously when 
I change them..


Stefan

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Stéphane Mottelet

Hello,

Le 28/11/2019 à 18:54, Stefan Du Rietz a écrit :
Le Jeudi, Novembre 28, 2019 17:05 CET, Claus Futtrup 
 a écrit:
  I think you can achieve what you want by setting ".visible='off'" 
for all the uicontrols you don't want to show initialy. You can then 
set  ".visible='on'" after the first call to the callback (or at each 
call if you are lazy).


I do that and it is very convenient. I also save my GUI data in a 
struct() in the "user_data" of the parent figure of the GUI.

So do I. Definitively the most handy way of  doing.

Then I don't need global variables or even findobj().

Regards
Stefan
___
users mailing list
users@lists.scilab.org
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users 



--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Samuel Gougeon

Le 28/11/2019 à 17:47, Antoine Monmayrant a écrit :

.../...
Also, you should better use get(a, 'propertyName') or set(a, 'propertyName', 
value) instead of a.propertyName and a.propertyName=value in your callbacks.
I have found that this latter syntax is causing a lot of bug if your callback 
get called really often. I still don't know why.



OK. Now i remember, indeed, that some handle.prop access are badly 
parsed as reading or defining a structure instead of reading or setting 
the (expectedly) defined handle...



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Samuel Gougeon

Le 28/11/2019 à 18:54, Stefan Du Rietz a écrit :


I do that and it is very convenient. I also save my GUI data in a 
struct() in the "user_data" of the parent figure of the GUI. Then I 
don't need global variables or even findobj().


If the stored data are not handles, this could be a bit risky or buggy: 
The graphics may be updated in the meantime, unlike the stored data... 
that then get outdated.


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Samuel Gougeon

Le 28/11/2019 à 19:40, Claus Futtrup a écrit :

Hi Antoine

Also, you should better use get(a, 'propertyName') or set(a, 
'propertyName', value) instead of a.propertyName and 
a.propertyName=value in your callbacks.



Why? It should be strictly equivalent, doesn't it?

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Claus Futtrup

Hi Antoine

Also, you should better use get(a, 'propertyName') or set(a, 'propertyName', 
value) instead of a.propertyName and a.propertyName=value in your callbacks.


I see what you mean. I just now had trouble turning visibility on/off, 
but using set(), it works fine. Thanks for the tip.


Best regards,
Claus

On 28.11.2019 17:47, Antoine Monmayrant wrote:

Le Jeudi, Novembre 28, 2019 17:05 CET, Claus Futtrup  a 
écrit:
  

Hi Antoine, et al.

Your reply is very helpful, so I think you got the right question :-)

1) Good point that I can use callback on every uicontrol. This would be
suitable for a simple example (like gui_example.sce) ... but for heavy
calculations, it might be more practical with a CALC button. P.S. The
correct equation for the resonance frequency is fres=sqrt(k/m)/(2*%pi);

You are right.
Also, the trick to disable the callback function/ reenable it is key for 
sliders that tend to generate an avalanche of call to the function when one 
moves the cursor.


2) I see what you mean, so not having an empty space, but "show" the
whole she-bang from the beginning. I didn't want to do that (just
deleting the IF-statement), but it could be the best solution in the end
(rather than the inline GUI updates), if nothing better shows up. This
was somehow the "core" of my question. Maybe I ask for too much.

I think you can achieve what you want by setting ".visible='off'" for all the uicontrols 
you don't want to show initialy. You can then set  ".visible='on'" after the first call 
to the callback (or at each call if you are lazy).


3) I will look into this. Thanks for the tip.

Also, you should better use get(a, 'propertyName') or set(a, 'propertyName', 
value) instead of a.propertyName and a.propertyName=value in your callbacks.
I have found that this latter syntax is causing a lot of bug if your callback 
get called really often. I still don't know why.


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 appreciate gui_example.sce with just about 70 lines of code, two
inputs and one output. I think something like it could help a lot of
people ... and it's not 250 lines of code to get a GUI up and running,
if you know what I mean. The gui_example shows a few differences, like
white versus grey background, editable boxes, etc. In the outputs,
because of the default grey background, you can see the dimensions of
the grid / text-boxes, and gui_example has two buttons. It looks
operational and easy to expand for new users.

Cheers,
Claus

On 28.11.2019 08:57, Antoine Monmayrant wrote:

Hello Claus,

I've been playing a bit with GUIs for teaching, so maybe I can help.
The issue is that I don't get what your problem is exactly here, so I my answer 
might be a bit off-topic.
Do not hesitate to rephrase your issue, I'll try a more focused answer.

Anywya, here is how I think your code could be improved:

(1) You can use 'calc' as the callback for all of the editable text field so 
that your result gets shown right away, without having to press a button.
(2) You should populate all the uicontrols of your gui first, then only update 
the displayed values, the visibility of the uicontrols, etc inside your calc 
function. (ie no more creating a uicontrol inside a callback)
(3) The 'tag' property of any uicontrol together with 'findobj()' are really 
nice to get/set the properties of each existing uicontrol.
(4) You can rely on a proper Model-View-Controler approach (or any other well 
established method to avoid mixing gui stuff with calculation stuff).

I attached a small gui I use to illustrate optical anti-reflection coating.
It is far from perfect (I did not implement a proper model-view-controler for 
example).
But you can see how I tried to separate the different parts of the code an how 
I use findobj/tag/get/set,  etc.

Hope it helps,

Antoine
   
Le Mercredi, Novembre 27, 2019 19:21 CET, Claus Futtrup  a écrit:
   

Hi there

I'm trying to build a GUI. For simplicity on the forum, I've built a
really simple example of what I'm trying to do. How can I make the
"conditional" GUI output work and not have it inside the calc function?
... or, how would you do it? Thanks.

Best regards, Claus.

// GUI_EXAMPLE.SCE
//
// Demo of how to build a simple GUI in Scilab.
// Real simple, with two input variables and one output.
// The example uses the basic mechanical example of a mass and a spring as
// input parameters and calculates the resonance frequency of the mechanical
// system.

// Initialize variables
m  =  1;  // Moving mass 

Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Claus Futtrup

Hi Stefan

>save my GUI data in a struct() in the "user_data"

I don't understand. Can you show me an example to explain this?

Best regards,
Claus

On 28.11.2019 18:54, Stefan Du Rietz wrote:
Le Jeudi, Novembre 28, 2019 17:05 CET, Claus Futtrup 
 a écrit:
  I think you can achieve what you want by setting ".visible='off'" 
for all the uicontrols you don't want to show initialy. You can then 
set  ".visible='on'" after the first call to the callback (or at each 
call if you are lazy).


I do that and it is very convenient. I also save my GUI data in a 
struct() in the "user_data" of the parent figure of the GUI. Then I 
don't need global variables or even findobj().


Regards
Stefan
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Claus Futtrup

Hi Antoine and Stefan

Thanks for the tip using visible='off' ... it looks like a better way.

Regards,
Claus

On 28.11.2019 18:54, Stefan Du Rietz wrote:
Le Jeudi, Novembre 28, 2019 17:05 CET, Claus Futtrup 
 a écrit:
  I think you can achieve what you want by setting ".visible='off'" 
for all the uicontrols you don't want to show initialy. You can then 
set  ".visible='on'" after the first call to the callback (or at each 
call if you are lazy).


I do that and it is very convenient. I also save my GUI data in a 
struct() in the "user_data" of the parent figure of the GUI. Then I 
don't need global variables or even findobj().


Regards
Stefan
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] ?= GUI hel

2019-11-28 Thread Stefan Du Rietz

Le Jeudi, Novembre 28, 2019 17:05 CET, Claus Futtrup  a 
écrit:
  
I think you can achieve what you want by setting ".visible='off'" for all the uicontrols you don't want to show initialy. You can then set  ".visible='on'" after the first call to the callback (or at each call if you are lazy).


I do that and it is very convenient. I also save my GUI data in a 
struct() in the "user_data" of the parent figure of the GUI. Then I 
don't need global variables or even findobj().


Regards
Stefan
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users