Programming GUI Tools

Example 1 - TextBox Control

library guitools;
#include guitools.sdf;
struct gstruct g0;
g0 = guiSet;

g0.command = textbox;
g0.title = "Text Box Example";
g0.prompt = "Enter your name";
name = guiRun(g0);

"Your name is: " name;

The first four lines set up the library and GUI structure.  The structure is populated with the command, title and prompt components, and the interface is displayed with the guiRun command, which returns the text input in name.

 

Example 2 - File Browser Dialog

library guitools;
#include guitools.sdf;
struct gstruct g0;
g0 = guiSet;

g0.command = filedlg;
g0.title = "Select file";
fname = guiRun(g0);

if strlen(fname) > 0;
"You selected: " fname;
else;
"No file was selected";
endif;

The first four lines set up the library and GUI structure.  The structure is populated with the command and  title components, and the dialog is displayed with the guiRun command, which returns the string  fname.

 

Example 3 - Custom GUI

library guitools;
#include guitools.sdf;
struct gstruct g0;
g0 = guiSet;

g0.filename = guipath $+ "beaver.gui";
call guiRun(g0);


cls;
format /rd 2,0;
" Values returned";
" ";
" Control Name Control Value ";
" ";
" User Name ";; varget("Username");
" Password  ";; varget("Password");
"";
" English   ";; varget("English_o");
" Spanish   ";; varget("Spanish_o");
" Chippeway ";; varget("Chippeway_o");
"";
" OK_b      ";; varget("ok_b");

This is a custom GUI for the Playful Beaver login form.    Each control is given a name in the properties window, and the characteristic of that control is saved in GAUSS under that name. Thus a text box called  username will return the string entered in the textbox.  If the user had entered 'Suzie Que' will be available in GAUSS as if the user had typed at the GAUSS prompt: 

	username = "Suzie Que";

The GUI description file is specified in g0.filename.  After guiRun has been executed, the programmer polls each variable to see the respective control's contents.  Check boxes, option and command buttons, and sliders return values, while most other controls return strings.  In this context, the username and password are returned as strings, the selected language option is returned as a scalar (1 checked, 0 not checked), and the command button as a scalar (1 clicked, 0 not clicked).

For interactive use in an econometric context, GUI Tools provides a much more attractive front end than simply editing a command file.  For example, see the custom GUI for the Black & Scholes model.

GUI Tools is relatively powerful.  It permits program calls, window states of both GAUSS and the GUI, and execution of text strings by GAUSS.  See the download section for more details in the manual.