blob: bacbf76868e36e705f93e998ba9be0a19850311c [file] [log] [blame]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00001\section{Built-in Module \sectcode{fl}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-fl}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00003\bimodindex{fl}
4
5This module provides an interface to the FORMS Library by Mark
Guido van Rossum470be141995-03-17 16:07:09 +00006Overmars. The source for the library can be retrieved by anonymous
7ftp from host \samp{ftp.cs.ruu.nl}, directory \file{SGI/FORMS}. It
8was last tested with version 2.0b.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00009
10Most functions are literal translations of their C equivalents,
Guido van Rossum470be141995-03-17 16:07:09 +000011dropping the initial \samp{fl_} from their name. Constants used by
12the library are defined in module \code{FL} described below.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000013
14The creation of objects is a little different in Python than in C:
15instead of the `current form' maintained by the library to which new
16FORMS objects are added, all functions that add a FORMS object to a
Guido van Rossum470be141995-03-17 16:07:09 +000017form are methods of the Python object representing the form.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000018Consequently, there are no Python equivalents for the C functions
19\code{fl_addto_form} and \code{fl_end_form}, and the equivalent of
20\code{fl_bgn_form} is called \code{fl.make_form}.
21
22Watch out for the somewhat confusing terminology: FORMS uses the word
23\dfn{object} for the buttons, sliders etc. that you can place in a form.
24In Python, `object' means any value. The Python interface to FORMS
25introduces two new Python object types: form objects (representing an
26entire form) and FORMS objects (representing one button, slider etc.).
27Hopefully this isn't too confusing...
28
29There are no `free objects' in the Python interface to FORMS, nor is
30there an easy way to add object classes written in Python. The FORMS
Guido van Rossum470be141995-03-17 16:07:09 +000031interface to GL event handling is available, though, so you can mix
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000032FORMS with pure GL windows.
33
34\strong{Please note:} importing \code{fl} implies a call to the GL function
35\code{foreground()} and to the FORMS routine \code{fl_init()}.
36
Guido van Rossum470be141995-03-17 16:07:09 +000037\subsection{Functions Defined in Module \sectcode{fl}}
Guido van Rossum86cb0921995-03-20 12:59:56 +000038\nodename{FL Functions}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000039
40Module \code{fl} defines the following functions. For more information
41about what they do, see the description of the equivalent C function
42in the FORMS documentation:
43
44\renewcommand{\indexsubitem}{(in module fl)}
45\begin{funcdesc}{make_form}{type\, width\, height}
46Create a form with given type, width and height. This returns a
47\dfn{form} object, whose methods are described below.
48\end{funcdesc}
49
50\begin{funcdesc}{do_forms}{}
51The standard FORMS main loop. Returns a Python object representing
52the FORMS object needing interaction, or the special value
53\code{FL.EVENT}.
54\end{funcdesc}
55
56\begin{funcdesc}{check_forms}{}
57Check for FORMS events. Returns what \code{do_forms} above returns,
58or \code{None} if there is no event that immediately needs
59interaction.
60\end{funcdesc}
61
62\begin{funcdesc}{set_event_call_back}{function}
63Set the event callback function.
64\end{funcdesc}
65
66\begin{funcdesc}{set_graphics_mode}{rgbmode\, doublebuffering}
67Set the graphics modes.
68\end{funcdesc}
69
70\begin{funcdesc}{get_rgbmode}{}
71Return the current rgb mode. This is the value of the C global
72variable \code{fl_rgbmode}.
73\end{funcdesc}
74
75\begin{funcdesc}{show_message}{str1\, str2\, str3}
76Show a dialog box with a three-line message and an OK button.
77\end{funcdesc}
78
79\begin{funcdesc}{show_question}{str1\, str2\, str3}
80Show a dialog box with a three-line message and YES and NO buttons.
81It returns \code{1} if the user pressed YES, \code{0} if NO.
82\end{funcdesc}
83
Guido van Rossum16d6e711994-08-08 12:30:22 +000084\begin{funcdesc}{show_choice}{str1\, str2\, str3\, but1\optional{\, but2\,
85but3}}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000086Show a dialog box with a three-line message and up to three buttons.
87It returns the number of the button clicked by the user
88(\code{1}, \code{2} or \code{3}).
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000089\end{funcdesc}
90
91\begin{funcdesc}{show_input}{prompt\, default}
92Show a dialog box with a one-line prompt message and text field in
93which the user can enter a string. The second argument is the default
94input string. It returns the string value as edited by the user.
95\end{funcdesc}
96
97\begin{funcdesc}{show_file_selector}{message\, directory\, pattern\, default}
Guido van Rossum470be141995-03-17 16:07:09 +000098Show a dialog box in which the user can select a file. It returns
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000099the absolute filename selected by the user, or \code{None} if the user
100presses Cancel.
101\end{funcdesc}
102
103\begin{funcdesc}{get_directory}{}
104\funcline{get_pattern}{}
105\funcline{get_filename}{}
106These functions return the directory, pattern and filename (the tail
107part only) selected by the user in the last \code{show_file_selector}
108call.
109\end{funcdesc}
110
111\begin{funcdesc}{qdevice}{dev}
112\funcline{unqdevice}{dev}
113\funcline{isqueued}{dev}
114\funcline{qtest}{}
115\funcline{qread}{}
116%\funcline{blkqread}{?}
117\funcline{qreset}{}
118\funcline{qenter}{dev\, val}
119\funcline{get_mouse}{}
120\funcline{tie}{button\, valuator1\, valuator2}
121These functions are the FORMS interfaces to the corresponding GL
122functions. Use these if you want to handle some GL events yourself
123when using \code{fl.do_events}. When a GL event is detected that
124FORMS cannot handle, \code{fl.do_forms()} returns the special value
125\code{FL.EVENT} and you should call \code{fl.qread()} to read the
126event from the queue. Don't use the equivalent GL functions!
127\end{funcdesc}
128
129\begin{funcdesc}{color}{}
130\funcline{mapcolor}{}
131\funcline{getmcolor}{}
132See the description in the FORMS documentation of \code{fl_color},
133\code{fl_mapcolor} and \code{fl_getmcolor}.
134\end{funcdesc}
135
Guido van Rossum470be141995-03-17 16:07:09 +0000136\subsection{Form Objects}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000137
138Form objects (returned by \code{fl.make_form()} above) have the
139following methods. Each method corresponds to a C function whose name
140is prefixed with \samp{fl_}; and whose first argument is a form
141pointer; please refer to the official FORMS documentation for
142descriptions.
143
144All the \samp{add_{\rm \ldots}} functions return a Python object representing
145the FORMS object. Methods of FORMS objects are described below. Most
146kinds of FORMS object also have some methods specific to that kind;
147these methods are listed here.
148
149\begin{flushleft}
150\renewcommand{\indexsubitem}{(form object method)}
151\begin{funcdesc}{show_form}{placement\, bordertype\, name}
152 Show the form.
153\end{funcdesc}
154
155\begin{funcdesc}{hide_form}{}
156 Hide the form.
157\end{funcdesc}
158
159\begin{funcdesc}{redraw_form}{}
160 Redraw the form.
161\end{funcdesc}
162
163\begin{funcdesc}{set_form_position}{x\, y}
164Set the form's position.
165\end{funcdesc}
166
167\begin{funcdesc}{freeze_form}{}
168Freeze the form.
169\end{funcdesc}
170
171\begin{funcdesc}{unfreeze_form}{}
172 Unfreeze the form.
173\end{funcdesc}
174
175\begin{funcdesc}{activate_form}{}
176 Activate the form.
177\end{funcdesc}
178
179\begin{funcdesc}{deactivate_form}{}
180 Deactivate the form.
181\end{funcdesc}
182
183\begin{funcdesc}{bgn_group}{}
184 Begin a new group of objects; return a group object.
185\end{funcdesc}
186
187\begin{funcdesc}{end_group}{}
188 End the current group of objects.
189\end{funcdesc}
190
191\begin{funcdesc}{find_first}{}
192 Find the first object in the form.
193\end{funcdesc}
194
195\begin{funcdesc}{find_last}{}
196 Find the last object in the form.
197\end{funcdesc}
198
199%---
200
201\begin{funcdesc}{add_box}{type\, x\, y\, w\, h\, name}
202Add a box object to the form.
203No extra methods.
204\end{funcdesc}
205
206\begin{funcdesc}{add_text}{type\, x\, y\, w\, h\, name}
207Add a text object to the form.
208No extra methods.
209\end{funcdesc}
210
211%\begin{funcdesc}{add_bitmap}{type\, x\, y\, w\, h\, name}
212%Add a bitmap object to the form.
213%\end{funcdesc}
214
215\begin{funcdesc}{add_clock}{type\, x\, y\, w\, h\, name}
216Add a clock object to the form. \\
217Method:
218\code{get_clock}.
219\end{funcdesc}
220
221%---
222
223\begin{funcdesc}{add_button}{type\, x\, y\, w\, h\, name}
224Add a button object to the form. \\
225Methods:
226\code{get_button},
227\code{set_button}.
228\end{funcdesc}
229
230\begin{funcdesc}{add_lightbutton}{type\, x\, y\, w\, h\, name}
231Add a lightbutton object to the form. \\
232Methods:
233\code{get_button},
234\code{set_button}.
235\end{funcdesc}
236
237\begin{funcdesc}{add_roundbutton}{type\, x\, y\, w\, h\, name}
238Add a roundbutton object to the form. \\
239Methods:
240\code{get_button},
241\code{set_button}.
242\end{funcdesc}
243
244%---
245
246\begin{funcdesc}{add_slider}{type\, x\, y\, w\, h\, name}
247Add a slider object to the form. \\
248Methods:
249\code{set_slider_value},
250\code{get_slider_value},
251\code{set_slider_bounds},
252\code{get_slider_bounds},
253\code{set_slider_return},
254\code{set_slider_size},
255\code{set_slider_precision},
256\code{set_slider_step}.
257\end{funcdesc}
258
259\begin{funcdesc}{add_valslider}{type\, x\, y\, w\, h\, name}
260Add a valslider object to the form. \\
261Methods:
262\code{set_slider_value},
263\code{get_slider_value},
264\code{set_slider_bounds},
265\code{get_slider_bounds},
266\code{set_slider_return},
267\code{set_slider_size},
268\code{set_slider_precision},
269\code{set_slider_step}.
270\end{funcdesc}
271
272\begin{funcdesc}{add_dial}{type\, x\, y\, w\, h\, name}
273Add a dial object to the form. \\
274Methods:
275\code{set_dial_value},
276\code{get_dial_value},
277\code{set_dial_bounds},
278\code{get_dial_bounds}.
279\end{funcdesc}
280
281\begin{funcdesc}{add_positioner}{type\, x\, y\, w\, h\, name}
282Add a positioner object to the form. \\
283Methods:
284\code{set_positioner_xvalue},
285\code{set_positioner_yvalue},
286\code{set_positioner_xbounds},
287\code{set_positioner_ybounds},
288\code{get_positioner_xvalue},
289\code{get_positioner_yvalue},
290\code{get_positioner_xbounds},
291\code{get_positioner_ybounds}.
292\end{funcdesc}
293
294\begin{funcdesc}{add_counter}{type\, x\, y\, w\, h\, name}
295Add a counter object to the form. \\
296Methods:
297\code{set_counter_value},
298\code{get_counter_value},
299\code{set_counter_bounds},
300\code{set_counter_step},
301\code{set_counter_precision},
302\code{set_counter_return}.
303\end{funcdesc}
304
305%---
306
307\begin{funcdesc}{add_input}{type\, x\, y\, w\, h\, name}
308Add a input object to the form. \\
309Methods:
310\code{set_input},
311\code{get_input},
312\code{set_input_color},
313\code{set_input_return}.
314\end{funcdesc}
315
316%---
317
318\begin{funcdesc}{add_menu}{type\, x\, y\, w\, h\, name}
319Add a menu object to the form. \\
320Methods:
321\code{set_menu},
322\code{get_menu},
323\code{addto_menu}.
324\end{funcdesc}
325
326\begin{funcdesc}{add_choice}{type\, x\, y\, w\, h\, name}
327Add a choice object to the form. \\
328Methods:
329\code{set_choice},
330\code{get_choice},
331\code{clear_choice},
332\code{addto_choice},
333\code{replace_choice},
334\code{delete_choice},
335\code{get_choice_text},
336\code{set_choice_fontsize},
337\code{set_choice_fontstyle}.
338\end{funcdesc}
339
340\begin{funcdesc}{add_browser}{type\, x\, y\, w\, h\, name}
341Add a browser object to the form. \\
342Methods:
343\code{set_browser_topline},
344\code{clear_browser},
345\code{add_browser_line},
346\code{addto_browser},
347\code{insert_browser_line},
348\code{delete_browser_line},
349\code{replace_browser_line},
350\code{get_browser_line},
351\code{load_browser},
352\code{get_browser_maxline},
353\code{select_browser_line},
354\code{deselect_browser_line},
355\code{deselect_browser},
356\code{isselected_browser_line},
357\code{get_browser},
358\code{set_browser_fontsize},
359\code{set_browser_fontstyle},
360\code{set_browser_specialkey}.
361\end{funcdesc}
362
363%---
364
365\begin{funcdesc}{add_timer}{type\, x\, y\, w\, h\, name}
366Add a timer object to the form. \\
367Methods:
368\code{set_timer},
369\code{get_timer}.
370\end{funcdesc}
371\end{flushleft}
372
373Form objects have the following data attributes; see the FORMS
374documentation:
375
376\begin{tableiii}{|l|c|l|}{code}{Name}{Type}{Meaning}
377 \lineiii{window}{int (read-only)}{GL window id}
378 \lineiii{w}{float}{form width}
379 \lineiii{h}{float}{form height}
380 \lineiii{x}{float}{form x origin}
381 \lineiii{y}{float}{form y origin}
382 \lineiii{deactivated}{int}{nonzero if form is deactivated}
383 \lineiii{visible}{int}{nonzero if form is visible}
384 \lineiii{frozen}{int}{nonzero if form is frozen}
385 \lineiii{doublebuf}{int}{nonzero if double buffering on}
386\end{tableiii}
387
Guido van Rossum470be141995-03-17 16:07:09 +0000388\subsection{FORMS Objects}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000389
390Besides methods specific to particular kinds of FORMS objects, all
391FORMS objects also have the following methods:
392
393\renewcommand{\indexsubitem}{(FORMS object method)}
394\begin{funcdesc}{set_call_back}{function\, argument}
395Set the object's callback function and argument. When the object
396needs interaction, the callback function will be called with two
397arguments: the object, and the callback argument. (FORMS objects
398without a callback function are returned by \code{fl.do_forms()} or
399\code{fl.check_forms()} when they need interaction.) Call this method
400without arguments to remove the callback function.
401\end{funcdesc}
402
403\begin{funcdesc}{delete_object}{}
404 Delete the object.
405\end{funcdesc}
406
407\begin{funcdesc}{show_object}{}
408 Show the object.
409\end{funcdesc}
410
411\begin{funcdesc}{hide_object}{}
412 Hide the object.
413\end{funcdesc}
414
415\begin{funcdesc}{redraw_object}{}
416 Redraw the object.
417\end{funcdesc}
418
419\begin{funcdesc}{freeze_object}{}
420 Freeze the object.
421\end{funcdesc}
422
423\begin{funcdesc}{unfreeze_object}{}
424 Unfreeze the object.
425\end{funcdesc}
426
427%\begin{funcdesc}{handle_object}{} XXX
428%\end{funcdesc}
429
430%\begin{funcdesc}{handle_object_direct}{} XXX
431%\end{funcdesc}
432
433FORMS objects have these data attributes; see the FORMS documentation:
434
435\begin{tableiii}{|l|c|l|}{code}{Name}{Type}{Meaning}
436 \lineiii{objclass}{int (read-only)}{object class}
437 \lineiii{type}{int (read-only)}{object type}
438 \lineiii{boxtype}{int}{box type}
439 \lineiii{x}{float}{x origin}
440 \lineiii{y}{float}{y origin}
441 \lineiii{w}{float}{width}
442 \lineiii{h}{float}{height}
443 \lineiii{col1}{int}{primary color}
444 \lineiii{col2}{int}{secondary color}
445 \lineiii{align}{int}{alignment}
446 \lineiii{lcol}{int}{label color}
447 \lineiii{lsize}{float}{label font size}
448 \lineiii{label}{string}{label string}
449 \lineiii{lstyle}{int}{label style}
450 \lineiii{pushed}{int (read-only)}{(see FORMS docs)}
451 \lineiii{focus}{int (read-only)}{(see FORMS docs)}
452 \lineiii{belowmouse}{int (read-only)}{(see FORMS docs)}
453 \lineiii{frozen}{int (read-only)}{(see FORMS docs)}
454 \lineiii{active}{int (read-only)}{(see FORMS docs)}
455 \lineiii{input}{int (read-only)}{(see FORMS docs)}
456 \lineiii{visible}{int (read-only)}{(see FORMS docs)}
457 \lineiii{radio}{int (read-only)}{(see FORMS docs)}
458 \lineiii{automatic}{int (read-only)}{(see FORMS docs)}
459\end{tableiii}
460
461\section{Standard Module \sectcode{FL}}
462\nodename{FL (uppercase)}
463\stmodindex{FL}
464
465This module defines symbolic constants needed to use the built-in
466module \code{fl} (see above); they are equivalent to those defined in
467the C header file \file{<forms.h>} except that the name prefix
468\samp{FL_} is omitted. Read the module source for a complete list of
469the defined names. Suggested use:
470
471\bcode\begin{verbatim}
472import fl
473from FL import *
474\end{verbatim}\ecode
Guido van Rossume47da0a1997-07-17 16:34:52 +0000475%
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000476\section{Standard Module \sectcode{flp}}
477\stmodindex{flp}
478
479This module defines functions that can read form definitions created
480by the `form designer' (\code{fdesign}) program that comes with the
481FORMS library (see module \code{fl} above).
482
483For now, see the file \file{flp.doc} in the Python library source
484directory for a description.
485
486XXX A complete description should be inserted here!