This version (0.82) of PgAccess introduce the visual form builder.
For the moment, it has only some basic widgets : labels, entries, buttons , listboxes , checkboxes and radiobuttons.
Also there is a query widget that allows you yo have access to a query results.
In a manner very similar with Visual Tcl or Visual Basic, the user must select a widget from the toolbar and drags on the canvas the rectangle that would define the widget. It can also specify some attributes in a separate window. Renaming, resizing items are possible modifying parameters in attribute window. Do not forget to press Enter in the edit field after changing a value in order to be accepted.
You can also move items by dragging them or delete them by pressing Del key.
In attribute window, there are some fields named Command and Variable.
The field Command have meaning only for Button widgets and holds the command that will be invoked when the button is pressed.
The field Variable have meaning only for EditField , Label widgets and checkboxes and it is the name of the global variable that will hold the value for that widget. For checkboxes the values are 1 or 0.
In order to make a simple test, put an entry field and set it's variable
to v1 and a button who's command is "set v1 whisky". Press the button
"Test form" and click on the button. In that entry should appear whisky.
Another test is defining in Script module a script called "My first
script" having the following commands:
tk_messageBox -title Warning -message "This is my
first message!"
and then define a button who's command is execute_script
"My first script".
Also, any widget will have the name prefixed by .mf We will have .mf.button1 or .mf.listbox1 .
We can name the query widget qry for example. The complete
name will be .mf.qry then.
The Command property of the query widget must contain
the SQL command that will be executed.
When the form will be in run-time, automatically you will have acces
to the following methods :
.mf.qry:execute - opens the connection and execute the query
(returns nothing)
.mf.qry:nrecords - returns the number of records in the selected
query
.mf.qry:fields - returns a list of the fields in the result
set
.mf.qry:movefirst - move the cursor to the first record in
the recordset
.mf.qry:movelast , .mf.qry:movenext , .mf.qry:moveprevious -
moves the cursor
.mf.qry:updatecontrols - update the variables inside the designed
form that have a particular name (I'll explain later)
.mf.qry:close - close the connection (if
you don't close the query result, you will loose memory)
If you want to bound some controls to the fields of the recordset, you will have to name their associate variable like that :
.mf.qry.salary to get the "salary" field , or .mf.qry.name to get the "name" field.
It's simple, isn't it ? It's just like a new widget that have some properties
and methods that can be accesed.
Also, the name convention is just like in Tcl/Tk.
In order to avoid naming user defined forms with a particular name of another PgAccess form, I would recommend naming them as udf0, udf1 (user defined form 0 , 1 )
Please feel free to send me your oppinion at teo@flex.ro on forms designing and usage.