Name

guimaker — Create a graphical user interface with a minimum of programming.

Calling Sequence

   [val1,val2,...]=guimaker(page,[guiProp],[DefProp],[Flag]) // interactive mode return user input from objects in the gui
   sci=guimaker(page,[guiProp],[DefProp],1) // return the Scilab source code required for generation of the gui
   links=guimaker(page,[guiProp],[DefProp],2) // create gui and return a list of handles to the gui objects
   guimaker() // runs a demo...
   

Parameters

page :

a list which defines the gui as a list of lines. Lines are counted from top to bottom of the gui.

line :

a line is defined as a list of objects. Empty elements are interpreted as empty places in the line.

object :

objects are defined as a list([whf],Style,String,Property1,Value1,Property2,Value2,...) or [] to indicate an empty position in the line.

whf :

OPTIONAL vector where whf(1) defines the object width relative to the width of the gui. whf(2) is the object height measured in number of lines. Default whf=[1 1]. Optional whf(3)=1 reduces the length of the object to fit into a frame.

Style :

string with the object type {pushbutton | radiobutton | checkbox | edit | text | slider | frame |listbox | popupmenu | axes}.

String :

string containing the 'string' value of the object.

Property :

string with object properties like { BackgroundColor | callback | fontangle | fontsize | fontunits | fontname | ForegroundColor | Horizontalalignment | ListboxTop | Max | Min | SliderStep | String | Tag | Units | Userdata | Value | Verticalalignment}. For axes objects see axes_properties.

Value :

value of the previous object property, see uicontrol for more details.

guiProp :

OPTIONAL list(Title,width,height,space,Backgroundcolor) defining gui window properties.

Title :

OPTIONAL string with name of the gui figure (default is 'guimaker').

width :

OPTIONAL width (points) of the gui window (default is 450).

height :

OPTIONAL height (points) of a line (default is 20).

space :

OPTIONAL space (points) between lines (first number) and objects on lines (second number) (default is [5 10])

Backgroundcolor :

OPTIONAL vector [R,G,B] with background color codes (default is [.95 .95 .95])

DefProp :

OPTIONAL list(Property1,Value1,...) with default properties for objects used in the gui.

Flag :

OPTIONAL =1: return Scilab code; =2: return list of object handles; ="filename": save/retrieve user input between successive calls to guimaker (values are stored in a file named 'TMPDIR\'+Flag).

links :

vector of object handles to each object in the gui (starting with the handle to the gui window and proceeds with objects from the top left to the bottom right position).

val1,val2,... :

results {string | value} from objects, except { pushbutton | text | frame }, in the order from the top left to the bottom right position in the gui. If only val1 is present the results are returned as a list.

Description

guimaker is a tool for creating a graphical user interface (gui) with a minimum of programming.

This is accomplished by describing the layout of the gui using a nested list. The input parameter page consists of a list of line elements. Each line element consists of a list of object elements, present in the line. Each object element consists of a list of elements describing the properties of the object (style, string and an arbitrary range of properties and property values).

The layout of the gui is defined by the way lines are counted from the top to the bottom of the gui, while objects in a line are counted from left to right. The objects on a line are distributed evenly in the horizontal direction. Using the optional object parameter wh one may change the size of individual objects in the horizontal and vertical direction.

guimaker can be used in three different modes:

  • Create a gui - including the event loop:

    Called with multiple output arguments ([val1,val2,...]=guimaker(...)) the output arguments will be assigned values from the "string" or "value" fields of objects present in the gui. The values are assigned to the output arguments according to the order the objects occur in the gui, counting objects from top left to the bottom right of the gui.

    If only one output argument is given the object values are returned as a list. Objects with style "pushbutton", "text" or "frame" do not return values.

    The gui is kept open until a callback 'OK=%T;' is executed by one of the objects in the GUI. If a callback 'CANCEL=%T;' is executed or if the gui window is killed, all output arguments are returned empty.

    The user must define an object (usually a pushbutton) with callback set to 'OK=%T;' and optionally also an object with callback set to 'CANCEL=%T;' - to implement a Cancel function. If the Flag input parameter is set to a valid file name the object values {string | value } will be stored in the temporary directory TMPDIR under the filename Flag. Initial object values will be read from this file during future calls within the current Scilab session.

  • Creation of a gui with no event loop:

    If the input argument Flag is equal to 2 guimaker will create the gui and return a vector of handles. links(1) is the handle to the gui figure window, while link(2:$) are handles to each object present in the gui (the handles are listed counting from top left to bottom right in the gui).

  • Create only the source code for a gui, but not the gui itself:

    Called with one output parameter and the Flag input parameter set to 1 guimaker will return the source code for the gui as a string matrix. The resulting code can be used and modified independently of guimaker.

Examples

// Example from http://wiki.scilab.org/howto/guicontrol
page=list();
page($+1)=list(list([1 10],'frame','General properties'));
page($+1)=list(list('text','Particle diameter [nm]'),list('edit','1000'));
page($+1)=list(list('text','Particle density [g/cm3]'),list('edit','1'));
page($+1)=list(list('text','Gas viscosity (0C) u [N*sec/m2]'),list('edit','0.0000172'));
page($+1)=list(list('text','Gas density (0C), 1 atm [kg/m3]'),list('edit','1.29'));
page($+1)=list(list('text','Mean free path (0C), 1 atm [nm]'),list('edit','67'));
page($+1)=list(list('text','Gamma, Cv/Cp'),list('edit','1.4'));
page($+1)=list(list('text','Sutherlands temperature, [K]'),list('edit','110.4'));
page($+1)=list(list('text','Temperature, [K]'),list('edit','300'));
page($+1)=list(list('text','Volume flow rate [standard l/min]'),list('edit','0.5'));
page($+1)=list(list([1 4],'frame','Telescope properties'));
page($+1)=list(list('text','Orifice diameters [mm]'),list('edit','1,1,1,1,1'));
page($+1)=list(list('text','Tube diameters [mm]'),list('edit','100,100,100,100,100'));
page($+1)=list(list('text','Input diameters [mm]'),list('edit','201325'));
page($+1)=list(list(2),list('pushbutton','Stop','callback','OK=%t'),list(2));
[dp,rhop,mu0,rhog0,lambda0,CvCp,S,T,mdot,df,ds,pin]=guimaker(page,list('Aerodynamic Lens Design'))

// Another example from http://wiki.scilab.org/howto/guicontrol
pg=list();
pg($+1)=list(list('text','exposure time','Horizontalalignment','center'));
pg($+1)=list(list('slider','','Min',0,'Max',100,'Value',5));
pg($+1)=list(list('text','arevscale','Horizontalalignment','center'));
pg($+1)=list(list('slider','','Min',0,'Max',100,'Value',50));
pg($+1)=list(list([1 2],'pushbutton','STOP','callback','OK=%t'),list(2,'radiobutton','bin x2'));
pg($+1)=list(list(1),list(2,'radiobutton','free/trig'));
[hexp,hbri,hbin,htrig]=guimaker(pg,list('objfigure1',220,[],[10 10]))

// If Flag is set to a valid file name the results are stored in TMPDIR/Flag...
[output]=guimaker(pg,list('Change some values and press STOP',220,[],[10 10]),[],'tmp_file')

// ... and subsequent calls will read the initial values from TMPDIR/Flag.
[output]=guimaker(pg,list('...remembers previous values.',220,[],[10 10]),[],'tmp_file')

// Source code generation:
source_code = guimaker(pg,list('objfigure1',220),[],1) // The code may be used as a template.
fn=TMPDIR+filesep()+'guitemplate.sce';
f=mopen(fn,'w'); mputl(source_code,f); mclose(f);
editor(fn); // Use this code as basis for more advanced programming

// Create gui and return a list of handles to objects in the gui:
h=guimaker(pg,list('objfigure1',220),[],2)  // returns a vector of object handles
// The object handles may be used in an external event control loop.
//
// -----------------------------------------
// See the guimaker demos for more examples.
// -----------------------------------------
   

See also

inputui, menumaker

Bibliography

http://wiki.scilab.org/howto/guicontrol ; provides more information on gui's in Scilab.

Authors

T. Pettersen, top@tpett.com