|
| 1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
1 | 2 | <HTML>
|
2 | 3 | <HEAD>
|
| 4 | + <TITLE></TITLE> |
3 | 5 | <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
4 |
| - <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i586) [Netscape]"> |
| 6 | + <META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.32 i586) [Netscape]"> |
5 | 7 | </HEAD>
|
6 | 8 | <BODY TEXT="#000000" BGCOLOR="#FFEBCD" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
|
7 | 9 |
|
8 |
| -<H1> |
9 |
| -FORMS</H1> |
| 10 | +<H1>FORMS</H1> |
10 | 11 |
|
11 |
| -<HR WIDTH="100%"> |
| 12 | +<P> |
| 13 | +<HR WIDTH="100%"></P> |
12 | 14 |
|
13 |
| -<P>This version (0.82) of PgAccess introduce the visual form builder. |
| 15 | +<P>This version (0.83) of PgAccess has changed a little the visual form |
| 16 | +builder introduced since 0.82 version : variable handling, query-results |
| 17 | +interface and control bindings naming convention. Please read it carefully, |
| 18 | +download the database demo and practice a while before trying to design |
| 19 | +your own forms.</P> |
14 | 20 |
|
15 | 21 | <P>For the moment, it has only some basic widgets : labels, entries, buttons
|
16 |
| -, listboxes , checkboxes and radiobuttons. |
| 22 | +, listboxes , checkboxes and radiobuttons.</P> |
| 23 | + |
| 24 | +<P>Also there is a pseudo query widget that allows you yo have access to |
| 25 | +a query results. </P> |
| 26 | + |
| 27 | +<P><B>How do you generate widgets :</B></P> |
| 28 | + |
| 29 | +<OL> |
| 30 | +<LI>select a widget from the toolbox by clicking the appropriate radiobutton</LI> |
| 31 | + |
| 32 | +<LI>move to the canvas , point with the mouse at the desired location and |
| 33 | +click the mouse button to begin</LI> |
| 34 | + |
| 35 | +<LI>keeping the mouse-button pressed move the mouse in order to draw a |
| 36 | +rectangle that will hold the widget</LI> |
17 | 37 |
|
18 |
| -<P>Also there is a query widget that allows you yo have access to a query |
19 |
| -results. |
| 38 | +<LI>release the mouse-button </LI> |
| 39 | +</OL> |
20 | 40 |
|
21 |
| -<P>In a manner very similar with Visual Tcl or Visual Basic, the user must |
22 |
| -select a widget from the toolbar and drags on the canvas the rectangle |
23 |
| -that would define the widget. It can also specify some attributes in a |
24 |
| -separate window. Renaming, resizing items are possible modifying parameters |
25 |
| -in attribute window. Do not forget to press Enter in the edit field after |
26 |
| -changing a value in order to be accepted. |
| 41 | +<P>In the rectangle that you have designed it will appear the selected |
| 42 | +object.<BR> |
| 43 | +Move now to the attribute window to change some of its properties.</P> |
| 44 | + |
| 45 | +<P>Renaming, resizing items are possible (for the moment) only by modifying |
| 46 | +appropriate parameters in attribute window. You <B>must </B>press Enter |
| 47 | +in the edit field after changing a value in order to be accepted. </P> |
27 | 48 |
|
28 | 49 | <P>You can also move items by dragging them or delete them by pressing
|
29 |
| -Del key. |
| 50 | +Del key after selecting them.</P> |
30 | 51 |
|
31 | 52 | <P>In attribute window, there are some fields named <B><TT><FONT SIZE=+1>Command
|
32 |
| -</FONT></TT></B>and <B><TT><FONT SIZE=+1>Variable</FONT></TT></B>. |
| 53 | +</FONT></TT></B>and <B><TT><FONT SIZE=+1>Variable</FONT></TT></B>. </P> |
33 | 54 |
|
34 | 55 | <P>The field <B><TT><FONT SIZE=+1>Command </FONT></TT></B>have meaning
|
35 | 56 | only for Button widgets and holds the command that will be invoked when
|
36 |
| -the button is pressed. |
37 |
| - |
38 |
| -<P>The field <B><TT><FONT SIZE=+1>Variable </FONT></TT></B>have meaning |
39 |
| -only for EditField , Label widgets and checkboxes and it is the name of |
40 |
| -the global variable that will hold the value for that widget. For checkboxes |
41 |
| -the values are 1 or 0. |
42 |
| - |
43 |
| -<P>In order to make a simple test, put an entry field and set it's variable |
44 |
| -to <B>v1</B> and a button who's command is "set v1 whisky". Press the button |
45 |
| -"Test form" and click on the button. In that entry should appear whisky. |
46 |
| -<BR>Another test is defining in Script module a script called "My first |
47 |
| -script" having the following commands: |
48 |
| -<BR><TT><FONT SIZE=+1>tk_messageBox -title Warning -message "This is my |
49 |
| -first message!"</FONT></TT> |
50 |
| -<BR>and then define a button who's command is <B><TT><FONT SIZE=+1>execute_script |
51 |
| -"My first script"</FONT></TT></B>. |
52 |
| -<H2> |
53 |
| -Database manipulation</H2> |
54 |
| -Let's presume that our form have the internal name <B><TT>mf </TT></B>(my |
55 |
| -form). He wil be referred inside the Tcl/Tk source as <B><TT>.mf</TT></B> |
56 |
| -<BR>If you want to close the form in run-time you have to issue the command |
57 |
| -<B><TT>destroy .mf</TT></B> |
| 57 | +the button is pressed. </P> |
| 58 | + |
| 59 | +<P> The field <B><TT><FONT SIZE=+1>Variable </FONT></TT></B>have |
| 60 | +meaning only for EditField , Label widgets , checkboxes and radiobuttons |
| 61 | +and it is the name of the global variable that will hold the value for |
| 62 | +that widget. For checkboxes the values are <B>t</B> and <B>f</B> (from |
| 63 | +true and false) in order to simplify binding to logical data fields (PgAccess |
| 64 | +0.82 used 0 and 1).</P> |
| 65 | + |
| 66 | +<P> For radiobuttons, it is usual to assign the |
| 67 | +same variable to the same radiobuttons within the same group. That variable |
| 68 | +will contain the name of the widget of the radiobutton that has been pressed. |
| 69 | +Let's presume that you have entered 3 radiobuttons named red, green and |
| 70 | +blue, all of them having the same variable named color. If you will press |
| 71 | +them, they will assign their names to global variable.</P> |
| 72 | + |
| 73 | +<P> In order to make a simple test, put an entry |
| 74 | +field and set it's variable to <B>v1</B> and a button who's command is |
| 75 | +"set v1 whisky". Press the button "Test form" and click |
| 76 | +on the button. In that entry should appear whisky. <BR> |
| 77 | +Another test is defining in Script module a script called "My first |
| 78 | +script" having the following commands: <BR> |
| 79 | +<TT><FONT SIZE=+1>tk_messageBox -title Warning -message "This is my |
| 80 | +first message!"</FONT></TT> <BR> |
| 81 | +and then define a button who's command is <B><TT><FONT SIZE=+1>execute_script |
| 82 | +"My first script"</FONT></TT></B>. </P> |
| 83 | + |
| 84 | +<H2>Database manipulation</H2> |
| 85 | + |
| 86 | +<P>Let's presume that our form have the internal name <B><TT>mf </TT></B>(my |
| 87 | +form). He will be referred inside the Tcl/Tk source as <B><TT>.mf</TT></B> |
| 88 | +<BR> |
| 89 | +If you want to close the form in run-time you have to issue the command |
| 90 | +<B><TT>destroy .mf</TT></B> </P> |
58 | 91 |
|
59 | 92 | <P>Also, any widget will have the name prefixed by <B><TT>.mf </TT></B>
|
60 | 93 | We will have <B><TT>.mf.button1</TT></B> or <B><TT>.mf.listbox1</TT></B>
|
61 |
| -. |
| 94 | +. </P> |
62 | 95 |
|
63 | 96 | <P>We can name the query widget <B><TT>qry</TT></B> for example. The complete
|
64 |
| -name will be <B><TT>.mf.qry</TT></B> then. |
65 |
| -<BR>The <B><TT>Command </TT></B>property of the query widget must contain |
66 |
| -the SQL command that will be executed. |
67 |
| -<BR>When the form will be in run-time, automatically you will have acces |
68 |
| -to the following methods : |
69 |
| - |
70 |
| -<P><TT>.mf.qry:execute</TT> - opens the connection and execute the query |
71 |
| -(returns nothing) |
72 |
| -<BR><TT>.mf.qry:nrecords</TT> - returns the number of records in the selected |
73 |
| -query |
74 |
| -<BR><TT>.mf.qry:fields</TT> - returns a list of the fields in the result |
75 |
| -set |
76 |
| -<BR><TT>.mf.qry:movefirst</TT> - move the cursor to the first record in |
77 |
| -the recordset |
78 |
| -<BR><TT>.mf.qry:movelast , .mf.qry:movenext , .mf.qry:moveprevious </TT>- |
79 |
| -moves the cursor |
80 |
| -<BR><TT>.mf.qry:updatecontrols</TT> - update the variables inside the designed |
81 |
| -form that have a particular name (I'll explain later) |
82 |
| -<BR><TT>.mf.qry:close</TT> - close the connection (<B><FONT COLOR="#FF0000">if |
83 |
| -you don't close the query result, you will loose memory</FONT></B>) |
| 97 | +name will be <B><TT>.mf.qry</TT></B> then. <BR> |
| 98 | +The <B><TT>Command </TT></B>property of the query widget must contain the |
| 99 | +SQL command that will be executed. <BR> |
| 100 | +When the form will be in run-time, automatically you will have acces to |
| 101 | +the following procedures and functions : </P> |
| 102 | + |
| 103 | +<P><B><TT>.mf.qry:open</TT></B> - opens the connection and execute the |
| 104 | +query (returns nothing) <BR> |
| 105 | +<B><TT>.mf.qry:setsql newsql</TT></B> - set the command query that will |
| 106 | +be executed at the next <B><TT>.mf.qry:open<BR> |
| 107 | +.mf.qry:nrecords</TT></B> - returns the number of records in the selected |
| 108 | +query <BR> |
| 109 | +<B><TT>.mf.qry:crtrecord </TT></B>- returns the current record number inside |
| 110 | +the query result<BR> |
| 111 | +<B><TT>.mf.qry:fields</TT></B> - returns a list of the fields in the result |
| 112 | +set <BR> |
| 113 | +<B><TT>.mf.qry:movefirst</TT></B> - move the cursor to the first record |
| 114 | +in the recordset <BR> |
| 115 | +<TT><B>.mf.qry:movelast</B> , <B>.mf.qry:movenext</B> , <B>.mf.qry:moveprevious</B> |
| 116 | +</TT>- moves the cursor there<BR> |
| 117 | +<B><TT>.mf.qry:moveto newrecno</TT></B> - move the cursor to that new record |
| 118 | +number (first is 0)<BR> |
| 119 | +<B><TT>.mf.qry:updatecontrols</TT></B> - update the variables inside the |
| 120 | +designed form that have a particular name (I'll explain later) <BR> |
| 121 | +<B><TT>.mf.qry:clearcontrols</TT></B> - clear the variables inside the |
| 122 | +designed form binded to a query result<BR> |
| 123 | +<TT><B>.mf.qry:fill listbox field</B> </TT>- fill the named listbox (whole |
| 124 | +widget name as <B><TT>.mf.listbox1</TT></B>) with the all the values of |
| 125 | +that field in the current queryresult<BR> |
| 126 | +<B><TT>.mf.qry:close</TT></B> - close the connection (<B><FONT COLOR="#FF0000">if |
| 127 | +you don't close the query result, you will loose some memory</FONT></B>) |
| 128 | +</P> |
| 129 | + |
| 130 | +<P>It's no need to close a query-result if you want to assign it a new |
| 131 | +SQL command and open it again. That will be done automatically.</P> |
84 | 132 |
|
85 | 133 | <P>If you want to bound some controls to the fields of the recordset, you
|
86 |
| -will have to name their associate variable like that : |
87 |
| - |
88 |
| -<P><TT>.mf.qry.salary</TT> to get the "salary" field , or <TT>.mf.qry.name</TT> |
89 |
| -to get the "name" field. |
90 |
| - |
91 |
| -<P>It's simple, isn't it ? It's just like a new widget that have some properties |
92 |
| -and methods that can be accesed. |
93 |
| -<BR>Also, the name convention is just like in Tcl/Tk. |
| 134 | +will have to name their associate variable like that : </P> |
| 135 | + |
| 136 | +<P><B><TT>mfqry(salary)</TT></B> to get the "salary" field , |
| 137 | +or <B><TT>mfqry(name)</TT></B> to get the "name" field. So, you |
| 138 | +take the internale name of the form (without the leading point) and merge |
| 139 | +it with the query-widget name and you will get a associative arrayname. |
| 140 | +The values are given using the field name as a key in this associative |
| 141 | +array.<BR> |
| 142 | +<B><FONT COLOR="#FF0000">* WARNING *</FONT></B> The naming style has been |
| 143 | +changed from 0.82 version of PgAccess and I cannot guarantee that it not |
| 144 | +be changed again in the future. I'm just trying to make it as simple it |
| 145 | +could be. The old style naming convention had some incompatibilities with |
| 146 | +Tcl/Tk syntax.</P> |
| 147 | + |
| 148 | +<P><B><FONT SIZE=+1><FONT COLOR="#9400D3">QUESTION</FONT> : </FONT></B>Do |
| 149 | +you think that it would be more clear if the above functions and procedures |
| 150 | +regarding a query-widget would be named in a similar manner as binded variable |
| 151 | +controls ? That mean, <B><TT>mfqry:open</TT></B> and <B><TT>mfqry:updatecontrols</TT></B> |
| 152 | +instead of <B><TT>.mf.qry:open</TT></B> and <B><TT>.mf.qry:updatecontrols</TT></B> |
| 153 | +?</P> |
| 154 | + |
| 155 | +<P>The only advantage of <B><TT>.mf.qry:open</TT></B> is that is much closer |
| 156 | +to the Tk method of referring objects within a window and it may give to |
| 157 | +the programmer the feeling that he is using a object-oriented widget. Since |
| 158 | +I cannot use further for naming binded variables a similar manner (<B><TT>.mf.qry.salary)</TT></B> |
| 159 | +it might be possible to abandon that naming convention .</P> |
| 160 | + |
| 161 | +<P>Here it is a dumped <B><A HREF="formdemo.sql">sample database</A></B> |
| 162 | +that contains a demo database. What should you do ?<BR> |
| 163 | +Shift-click the above URL in order to download that tiny file (4 Kb). Create |
| 164 | +a empty database and <B><TT>psql yourdatabase <formdemo.sql</TT></B></P> |
| 165 | + |
| 166 | +<P>You should find a single table called "phonebook" a form called |
| 167 | +"Phone book" and another "A simple demo form".</P> |
| 168 | + |
| 169 | +<P>First of all enter and view the phonebook table in table view. Note |
| 170 | +the fields and their values.<BR> |
| 171 | +Open the "Phone book" form and enter a letter (a, e or i) in |
| 172 | +the field to the left of "Find" button then press Find. It's |
| 173 | +fine to enter one letter in order to get more records in query result. |
| 174 | +You will get information about the number of records selected, in the listbox |
| 175 | +you will see all the values of field "name" from the current |
| 176 | +data set. Use buttons to move to first, next, previous or last record within |
| 177 | +the record set.</P> |
| 178 | + |
| 179 | +<P>In order to add a new record, press the "New" button in order |
| 180 | +to get new, clean entries. Fill them with your data and press "Add |
| 181 | +new" button. A new phonebook record will be added. Also, if you want |
| 182 | +to update a record, change it's values in the displayed fields after finding |
| 183 | +it and press "Update" button. The values will be updated in the |
| 184 | +database BUT NOT IN THE CURRENT QUERY RESULT . If you want to see them |
| 185 | +modified, make a new query trying to find it again.</P> |
| 186 | + |
| 187 | +<P><FONT COLOR="#000080">Before using the results from a query you should |
| 188 | +know that the information that has been retrieved could be found only in |
| 189 | +your computer client memory. It has <B>no live connection</B> to the data |
| 190 | +from the database. That's why it isn't possible to develop a simple update |
| 191 | +function as interface to that query-result widget. More than that : a query |
| 192 | +result could be obtained from a SQL command that return a non-updatable |
| 193 | +data set !!! For example fields gathered from multiple tables or summary |
| 194 | +fields. It isn't just simple to make an automatic update procedure. The |
| 195 | +programmer must know how to make the update or the append procedure, sometimes |
| 196 | +using key fields to point to the desired record or an OID. There are examples |
| 197 | +in the demo database in "Phone book" form. It may be possible |
| 198 | +that in the future, I will develop another pseudo-widget describing a table. |
| 199 | +It would be more simple than to implement an update or append or even a |
| 200 | +delete procedure.</FONT></P> |
| 201 | + |
| 202 | +<P>There is in the demo database also another simple form called "A |
| 203 | +simple demo form". It will show you how to handle variables from checkboxes, |
| 204 | +radiobuttons, how to use listboxes, open another forms and so on. I think |
| 205 | +they will help you.</P> |
94 | 206 |
|
95 | 207 | <P>In order to avoid naming user defined forms with a particular
|
96 | 208 | name of another PgAccess form, I would recommend naming them as udf0, udf1
|
97 |
| -(user defined form 0 , 1 ) |
| 209 | +(user defined form 0 , 1 ) </P> |
98 | 210 |
|
99 | 211 | <P>
|
100 |
| -<HR WIDTH="25%"> |
| 212 | +<HR WIDTH="25%"></P> |
101 | 213 |
|
102 | 214 | <P>Please feel free to send me your oppinion at <B>teo@flex.ro</B> on forms
|
103 |
| -designing and usage. |
| 215 | +designing and usage. </P> |
| 216 | + |
| 217 | +<P><B><FONT SIZE=+1>KEEP IN MIND ! THE |
| 218 | +FORM API WILL CHANGE IN ORDER TO BE MORE SIMPLE AND BETTER! SEND |
| 219 | +ME YOUR WISHES, YOUR IDEAS, YOUR OPINIONS !<BR> |
| 220 | +ALSO ... DON'T BLAME ME IF YOU WILL HAVE TO RE-DESIGN YOUR OLD FORMS DUE |
| 221 | +TO SOME INCOMPATIBILITIES WITH NEWER PGACCESS VERSIONS.</FONT></B></P> |
| 222 | + |
104 | 223 | </BODY>
|
105 | 224 | </HTML>
|
0 commit comments