[Scilab-users] Help write simple GUI

Claus Futtrup cfuttrup at gmail.com
Sun Jun 1 12:31:22 CEST 2014


Hi Antoine

Thank you for your suggestion, which almost does what I need. The users 
are not necessarily Scilab users, so I'd like a user interface where the 
result is also displayed.

I realize I could show a messagebox with the result.

What I'd like to do requires a single window/figure where input and 
output is shown + a QUIT button so that the user always only sees one 
single frame / user interface, as an application / for simplicity (no 
Scilab).

Later I will add a noise spectrum simulation + a filter - e.g. 2. order 
high-pass butterworth at 2500 Hz. The filtered response will reduce the 
voltage, but how much? The user should be informed about before + after 
filter (3 inputs, 2 outputs) and dialog boxes is not as nice when it's 
more complicated like this.

Best regards,
Claus

On 01-Jun-14 11:41, Antoine ELIAS wrote:
> Hi Claus,
>
> For small dialogs to ask inputs, use *x_mdialog* function ( 
> http://help.scilab.org/docs/5.5.0/fr_FR/x_mdialog.html )
>
> function result = compute_voltage()
>     txt = ['Power (Watt)';'Impedance (ohm)'];
>     values = *x_mdialog*('System values',txt,['100';'8'])
>     if values <> [] then
>         w = values(1);
>         o = values(2);
>         w = eval(w);
>         o = eval(o);
>
>         if typeof(w) <> "constant" | int(w) <> w | typeof(o) <> 
> "constant" | int(o) <> o then
>             error("bad value, integer values expected");
>         end
>
>         result = sqrt(w * o);
>     else
>         result = [];
>     end
> endfunction
>
> voltage = compute_voltage()
>
> Antoine
>
>
> Le 31/05/2014 22:01, Claus Futtrup a écrit :
>> Hi there
>>
>> I hope someone can help me make a simple GUI front end to my script, 
>> preferably without using GUI Builder or guimaker, because I think 
>> I'll understand better without using additional tools.
>>
>> The GUI - a window containing two variable input:
>> 1. text + input box + text
>>    Again the input is a number, typically an integer (as in "system 
>> power : 100 Watt"). 100 being the user variable input.
>> 2. text + input box + text
>>    A number, typically an intereger (as in "impedance : 8 ohm"). 8 
>> being the user variable input.
>>
>> The script will then based on 100 Watt into 8 ohm calculate the 
>> voltage = sqrt(100*8). I will round the number to one decimal, 
>> convert it to a string and create an answer, like "Input level : 28.3 
>> Volt".
>>
>> The GUI should contain two buttons, e.g. an OK + a QUIT button. The 
>> OK button runs the calculations. The quit button quits the script 
>> (may as well quit Scilab).
>>
>> I've studied the GUI controls in Scilab already and I understand the 
>> the old way of making a new window is:
>>
>> f = figure();
>>
>> but it seems there's a new command in Scilab 5.5.0:
>>
>> f = createWindow();
>>
>> The new method probably has its advantages, but the Scilab manual 
>> doesn't really explain... can anybody explain to me?
>>
>> Can you use the same uicontrol commands with both methods? (can I use 
>> examples found on the internet using "figure" and just replace figure 
>> with createWindow?). It seems to me that the examples in the 
>> createWindow gives uicontrol some inputs named "units" - "normalized" 
>> - etc. - which are not present when looking at old figure() examples.
>>
>> My next question will be, how do I create a uicontrol which accepts a 
>> string input (as I need 2 of those). The uicontrol documentation says 
>> the "Edit" style will do that. Funny, but also a bit strange, that 
>> you can find all sorts of examples for using uicontrol with 
>> checboxes, listboxes, radiobuttons, pushbuttons, tables etc. - but no 
>> examples are provided with this most useful editable string input ... 
>> (???)
>>
>> ... hereafter I expect to evaluate the two strings (or if they're 
>> returned as numbers, that's fine of course, I just don't need the 
>> script to crash if something is not right). Then execute my code.
>>
>> Best regards,
>> Claus
>>
>> ---
>> This email is free from viruses and malware because avast! Antivirus 
>> protection is active.
>> http://www.avast.com
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>
>
> -- 
> Antoine ELIAS
> Software developer
> -----------------------
> Scilab Enterprises
> 143bis rue Yves Le Coz - 78000 Versailles
> Phone: 01.80.77.04.70
> http://www.scilab-enterprises.com
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140601/3ed1c817/attachment.htm>


More information about the users mailing list