blob: 617a85200c3cb2e2bfbbca3f6fba99a071ab81b5 [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
Fred Drake0cf0cfb1998-02-19 20:59:19 +000010Most 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
Fred Drake0cf0cfb1998-02-19 20:59:19 +000012the library are defined in module \module{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
Fred Drake0cf0cfb1998-02-19 20:59:19 +000019\cfunction{fl_addto_form()} and \cfunction{fl_end_form()}, and the
20equivalent of \cfunction{fl_bgn_form()} is called
21\function{fl.make_form()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000022
23Watch out for the somewhat confusing terminology: FORMS uses the word
24\dfn{object} for the buttons, sliders etc. that you can place in a form.
25In Python, `object' means any value. The Python interface to FORMS
26introduces two new Python object types: form objects (representing an
27entire form) and FORMS objects (representing one button, slider etc.).
Fred Drake0cf0cfb1998-02-19 20:59:19 +000028Hopefully this isn't too confusing.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000029
30There are no `free objects' in the Python interface to FORMS, nor is
31there an easy way to add object classes written in Python. The FORMS
Guido van Rossum470be141995-03-17 16:07:09 +000032interface to GL event handling is available, though, so you can mix
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000033FORMS with pure GL windows.
34
Fred Drake0cf0cfb1998-02-19 20:59:19 +000035\strong{Please note:} importing \module{fl} implies a call to the GL
36function \cfunction{foreground()} and to the FORMS routine
37\cfunction{fl_init()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000038
Guido van Rossum470be141995-03-17 16:07:09 +000039\subsection{Functions Defined in Module \sectcode{fl}}
Guido van Rossum86cb0921995-03-20 12:59:56 +000040\nodename{FL Functions}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000041
Fred Drake0cf0cfb1998-02-19 20:59:19 +000042Module \module{fl} defines the following functions. For more
43information about what they do, see the description of the equivalent
44\C{} function in the FORMS documentation:
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000045
Fred Drake19479911998-02-13 06:58:54 +000046\setindexsubitem{(in module fl)}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000047\begin{funcdesc}{make_form}{type\, width\, height}
48Create a form with given type, width and height. This returns a
49\dfn{form} object, whose methods are described below.
50\end{funcdesc}
51
52\begin{funcdesc}{do_forms}{}
53The standard FORMS main loop. Returns a Python object representing
54the FORMS object needing interaction, or the special value
Fred Drake0cf0cfb1998-02-19 20:59:19 +000055\constant{FL.EVENT}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000056\end{funcdesc}
57
58\begin{funcdesc}{check_forms}{}
Fred Drake0cf0cfb1998-02-19 20:59:19 +000059Check for FORMS events. Returns what \function{do_forms()} above
60returns, or \code{None} if there is no event that immediately needs
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000061interaction.
62\end{funcdesc}
63
64\begin{funcdesc}{set_event_call_back}{function}
65Set the event callback function.
66\end{funcdesc}
67
68\begin{funcdesc}{set_graphics_mode}{rgbmode\, doublebuffering}
69Set the graphics modes.
70\end{funcdesc}
71
72\begin{funcdesc}{get_rgbmode}{}
73Return the current rgb mode. This is the value of the C global
Fred Drake0cf0cfb1998-02-19 20:59:19 +000074variable \cdata{fl_rgbmode}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000075\end{funcdesc}
76
77\begin{funcdesc}{show_message}{str1\, str2\, str3}
78Show a dialog box with a three-line message and an OK button.
79\end{funcdesc}
80
81\begin{funcdesc}{show_question}{str1\, str2\, str3}
82Show a dialog box with a three-line message and YES and NO buttons.
83It returns \code{1} if the user pressed YES, \code{0} if NO.
84\end{funcdesc}
85
Fred Drake1b6cf781997-12-29 20:28:33 +000086\begin{funcdesc}{show_choice}{str1, str2, str3, but1\optional{, but2, but3}}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000087Show a dialog box with a three-line message and up to three buttons.
88It returns the number of the button clicked by the user
89(\code{1}, \code{2} or \code{3}).
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000090\end{funcdesc}
91
92\begin{funcdesc}{show_input}{prompt\, default}
93Show a dialog box with a one-line prompt message and text field in
94which the user can enter a string. The second argument is the default
95input string. It returns the string value as edited by the user.
96\end{funcdesc}
97
98\begin{funcdesc}{show_file_selector}{message\, directory\, pattern\, default}
Guido van Rossum470be141995-03-17 16:07:09 +000099Show a dialog box in which the user can select a file. It returns
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000100the absolute filename selected by the user, or \code{None} if the user
101presses Cancel.
102\end{funcdesc}
103
104\begin{funcdesc}{get_directory}{}
105\funcline{get_pattern}{}
106\funcline{get_filename}{}
107These functions return the directory, pattern and filename (the tail
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000108part only) selected by the user in the last
109\function{show_file_selector()} call.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000110\end{funcdesc}
111
112\begin{funcdesc}{qdevice}{dev}
113\funcline{unqdevice}{dev}
114\funcline{isqueued}{dev}
115\funcline{qtest}{}
116\funcline{qread}{}
117%\funcline{blkqread}{?}
118\funcline{qreset}{}
119\funcline{qenter}{dev\, val}
120\funcline{get_mouse}{}
121\funcline{tie}{button\, valuator1\, valuator2}
122These functions are the FORMS interfaces to the corresponding GL
123functions. Use these if you want to handle some GL events yourself
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000124when using \function{fl.do_events()}. When a GL event is detected that
125FORMS cannot handle, \function{fl.do_forms()} returns the special value
126\constant{FL.EVENT} and you should call \function{fl.qread()} to read
127the event from the queue. Don't use the equivalent GL functions!
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000128\end{funcdesc}
129
130\begin{funcdesc}{color}{}
131\funcline{mapcolor}{}
132\funcline{getmcolor}{}
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000133See the description in the FORMS documentation of
134\cfunction{fl_color()}, \cfunction{fl_mapcolor()} and
135\cfunction{fl_getmcolor()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000136\end{funcdesc}
137
Guido van Rossum470be141995-03-17 16:07:09 +0000138\subsection{Form Objects}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000139
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000140Form objects (returned by \function{fl.make_form()} above) have the
141following methods. Each method corresponds to a \C{} function whose
142name is prefixed with \samp{fl_}; and whose first argument is a form
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000143pointer; please refer to the official FORMS documentation for
144descriptions.
145
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000146All the \samp{add_{\rm \ldots}} functions return a Python object
147representing the FORMS object. Methods of FORMS objects are described
148below. Most kinds of FORMS object also have some methods specific to
149that kind; these methods are listed here.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000150
151\begin{flushleft}
Fred Drake19479911998-02-13 06:58:54 +0000152\setindexsubitem{(form object method)}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000153\begin{funcdesc}{show_form}{placement\, bordertype\, name}
154 Show the form.
155\end{funcdesc}
156
157\begin{funcdesc}{hide_form}{}
158 Hide the form.
159\end{funcdesc}
160
161\begin{funcdesc}{redraw_form}{}
162 Redraw the form.
163\end{funcdesc}
164
165\begin{funcdesc}{set_form_position}{x\, y}
166Set the form's position.
167\end{funcdesc}
168
169\begin{funcdesc}{freeze_form}{}
170Freeze the form.
171\end{funcdesc}
172
173\begin{funcdesc}{unfreeze_form}{}
174 Unfreeze the form.
175\end{funcdesc}
176
177\begin{funcdesc}{activate_form}{}
178 Activate the form.
179\end{funcdesc}
180
181\begin{funcdesc}{deactivate_form}{}
182 Deactivate the form.
183\end{funcdesc}
184
185\begin{funcdesc}{bgn_group}{}
186 Begin a new group of objects; return a group object.
187\end{funcdesc}
188
189\begin{funcdesc}{end_group}{}
190 End the current group of objects.
191\end{funcdesc}
192
193\begin{funcdesc}{find_first}{}
194 Find the first object in the form.
195\end{funcdesc}
196
197\begin{funcdesc}{find_last}{}
198 Find the last object in the form.
199\end{funcdesc}
200
201%---
202
203\begin{funcdesc}{add_box}{type\, x\, y\, w\, h\, name}
204Add a box object to the form.
205No extra methods.
206\end{funcdesc}
207
208\begin{funcdesc}{add_text}{type\, x\, y\, w\, h\, name}
209Add a text object to the form.
210No extra methods.
211\end{funcdesc}
212
213%\begin{funcdesc}{add_bitmap}{type\, x\, y\, w\, h\, name}
214%Add a bitmap object to the form.
215%\end{funcdesc}
216
217\begin{funcdesc}{add_clock}{type\, x\, y\, w\, h\, name}
218Add a clock object to the form. \\
219Method:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000220\method{get_clock()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000221\end{funcdesc}
222
223%---
224
225\begin{funcdesc}{add_button}{type\, x\, y\, w\, h\, name}
226Add a button object to the form. \\
227Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000228\method{get_button()},
229\method{set_button()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000230\end{funcdesc}
231
232\begin{funcdesc}{add_lightbutton}{type\, x\, y\, w\, h\, name}
233Add a lightbutton object to the form. \\
234Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000235\method{get_button()},
236\method{set_button()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000237\end{funcdesc}
238
239\begin{funcdesc}{add_roundbutton}{type\, x\, y\, w\, h\, name}
240Add a roundbutton object to the form. \\
241Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000242\method{get_button()},
243\method{set_button()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000244\end{funcdesc}
245
246%---
247
248\begin{funcdesc}{add_slider}{type\, x\, y\, w\, h\, name}
249Add a slider object to the form. \\
250Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000251\method{set_slider_value()},
252\method{get_slider_value()},
253\method{set_slider_bounds()},
254\method{get_slider_bounds()},
255\method{set_slider_return()},
256\method{set_slider_size()},
257\method{set_slider_precision()},
258\method{set_slider_step()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000259\end{funcdesc}
260
261\begin{funcdesc}{add_valslider}{type\, x\, y\, w\, h\, name}
262Add a valslider object to the form. \\
263Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000264\method{set_slider_value()},
265\method{get_slider_value()},
266\method{set_slider_bounds()},
267\method{get_slider_bounds()},
268\method{set_slider_return()},
269\method{set_slider_size()},
270\method{set_slider_precision()},
271\method{set_slider_step()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000272\end{funcdesc}
273
274\begin{funcdesc}{add_dial}{type\, x\, y\, w\, h\, name}
275Add a dial object to the form. \\
276Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000277\method{set_dial_value()},
278\method{get_dial_value()},
279\method{set_dial_bounds()},
280\method{get_dial_bounds()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000281\end{funcdesc}
282
283\begin{funcdesc}{add_positioner}{type\, x\, y\, w\, h\, name}
284Add a positioner object to the form. \\
285Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000286\method{set_positioner_xvalue()},
287\method{set_positioner_yvalue()},
288\method{set_positioner_xbounds()},
289\method{set_positioner_ybounds()},
290\method{get_positioner_xvalue()},
291\method{get_positioner_yvalue()},
292\method{get_positioner_xbounds()},
293\method{get_positioner_ybounds()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000294\end{funcdesc}
295
296\begin{funcdesc}{add_counter}{type\, x\, y\, w\, h\, name}
297Add a counter object to the form. \\
298Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000299\method{set_counter_value()},
300\method{get_counter_value()},
301\method{set_counter_bounds()},
302\method{set_counter_step()},
303\method{set_counter_precision()},
304\method{set_counter_return()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000305\end{funcdesc}
306
307%---
308
309\begin{funcdesc}{add_input}{type\, x\, y\, w\, h\, name}
310Add a input object to the form. \\
311Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000312\method{set_input()},
313\method{get_input()},
314\method{set_input_color()},
315\method{set_input_return()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000316\end{funcdesc}
317
318%---
319
320\begin{funcdesc}{add_menu}{type\, x\, y\, w\, h\, name}
321Add a menu object to the form. \\
322Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000323\method{set_menu()},
324\method{get_menu()},
325\method{addto_menu()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000326\end{funcdesc}
327
328\begin{funcdesc}{add_choice}{type\, x\, y\, w\, h\, name}
329Add a choice object to the form. \\
330Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000331\method{set_choice()},
332\method{get_choice()},
333\method{clear_choice()},
334\method{addto_choice()},
335\method{replace_choice()},
336\method{delete_choice()},
337\method{get_choice_text()},
338\method{set_choice_fontsize()},
339\method{set_choice_fontstyle()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000340\end{funcdesc}
341
342\begin{funcdesc}{add_browser}{type\, x\, y\, w\, h\, name}
343Add a browser object to the form. \\
344Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000345\method{set_browser_topline()},
346\method{clear_browser()},
347\method{add_browser_line()},
348\method{addto_browser()},
349\method{insert_browser_line()},
350\method{delete_browser_line()},
351\method{replace_browser_line()},
352\method{get_browser_line()},
353\method{load_browser()},
354\method{get_browser_maxline()},
355\method{select_browser_line()},
356\method{deselect_browser_line()},
357\method{deselect_browser()},
358\method{isselected_browser_line()},
359\method{get_browser()},
360\method{set_browser_fontsize()},
361\method{set_browser_fontstyle()},
362\method{set_browser_specialkey()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000363\end{funcdesc}
364
365%---
366
367\begin{funcdesc}{add_timer}{type\, x\, y\, w\, h\, name}
368Add a timer object to the form. \\
369Methods:
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000370\method{set_timer()},
371\method{get_timer()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000372\end{funcdesc}
373\end{flushleft}
374
375Form objects have the following data attributes; see the FORMS
376documentation:
377
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000378\begin{tableiii}{|l|c|l|}{member}{Name}{Type}{Meaning}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000379 \lineiii{window}{int (read-only)}{GL window id}
380 \lineiii{w}{float}{form width}
381 \lineiii{h}{float}{form height}
382 \lineiii{x}{float}{form x origin}
383 \lineiii{y}{float}{form y origin}
384 \lineiii{deactivated}{int}{nonzero if form is deactivated}
385 \lineiii{visible}{int}{nonzero if form is visible}
386 \lineiii{frozen}{int}{nonzero if form is frozen}
387 \lineiii{doublebuf}{int}{nonzero if double buffering on}
388\end{tableiii}
389
Guido van Rossum470be141995-03-17 16:07:09 +0000390\subsection{FORMS Objects}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000391
392Besides methods specific to particular kinds of FORMS objects, all
393FORMS objects also have the following methods:
394
Fred Drake19479911998-02-13 06:58:54 +0000395\setindexsubitem{(FORMS object method)}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000396\begin{funcdesc}{set_call_back}{function\, argument}
397Set the object's callback function and argument. When the object
398needs interaction, the callback function will be called with two
399arguments: the object, and the callback argument. (FORMS objects
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000400without a callback function are returned by \function{fl.do_forms()}
401or \function{fl.check_forms()} when they need interaction.) Call this
402method without arguments to remove the callback function.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000403\end{funcdesc}
404
405\begin{funcdesc}{delete_object}{}
406 Delete the object.
407\end{funcdesc}
408
409\begin{funcdesc}{show_object}{}
410 Show the object.
411\end{funcdesc}
412
413\begin{funcdesc}{hide_object}{}
414 Hide the object.
415\end{funcdesc}
416
417\begin{funcdesc}{redraw_object}{}
418 Redraw the object.
419\end{funcdesc}
420
421\begin{funcdesc}{freeze_object}{}
422 Freeze the object.
423\end{funcdesc}
424
425\begin{funcdesc}{unfreeze_object}{}
426 Unfreeze the object.
427\end{funcdesc}
428
429%\begin{funcdesc}{handle_object}{} XXX
430%\end{funcdesc}
431
432%\begin{funcdesc}{handle_object_direct}{} XXX
433%\end{funcdesc}
434
435FORMS objects have these data attributes; see the FORMS documentation:
436
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000437\begin{tableiii}{|l|c|l|}{member}{Name}{Type}{Meaning}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000438 \lineiii{objclass}{int (read-only)}{object class}
439 \lineiii{type}{int (read-only)}{object type}
440 \lineiii{boxtype}{int}{box type}
441 \lineiii{x}{float}{x origin}
442 \lineiii{y}{float}{y origin}
443 \lineiii{w}{float}{width}
444 \lineiii{h}{float}{height}
445 \lineiii{col1}{int}{primary color}
446 \lineiii{col2}{int}{secondary color}
447 \lineiii{align}{int}{alignment}
448 \lineiii{lcol}{int}{label color}
449 \lineiii{lsize}{float}{label font size}
450 \lineiii{label}{string}{label string}
451 \lineiii{lstyle}{int}{label style}
452 \lineiii{pushed}{int (read-only)}{(see FORMS docs)}
453 \lineiii{focus}{int (read-only)}{(see FORMS docs)}
454 \lineiii{belowmouse}{int (read-only)}{(see FORMS docs)}
455 \lineiii{frozen}{int (read-only)}{(see FORMS docs)}
456 \lineiii{active}{int (read-only)}{(see FORMS docs)}
457 \lineiii{input}{int (read-only)}{(see FORMS docs)}
458 \lineiii{visible}{int (read-only)}{(see FORMS docs)}
459 \lineiii{radio}{int (read-only)}{(see FORMS docs)}
460 \lineiii{automatic}{int (read-only)}{(see FORMS docs)}
461\end{tableiii}
462
463\section{Standard Module \sectcode{FL}}
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000464\label{module-FLuppercase}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000465\stmodindex{FL}
466
467This module defines symbolic constants needed to use the built-in
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000468module \module{fl} (see above); they are equivalent to those defined in
469the \C{} header file \code{<forms.h>} except that the name prefix
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000470\samp{FL_} is omitted. Read the module source for a complete list of
471the defined names. Suggested use:
472
Fred Drake19479911998-02-13 06:58:54 +0000473\begin{verbatim}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000474import fl
475from FL import *
Fred Drake19479911998-02-13 06:58:54 +0000476\end{verbatim}
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000477
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000478\section{Standard Module \sectcode{flp}}
Fred Drakeb2151371998-01-14 05:47:15 +0000479\label{module-flp}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000480\stmodindex{flp}
481
482This module defines functions that can read form definitions created
Fred Drake0cf0cfb1998-02-19 20:59:19 +0000483by the `form designer' (\program{fdesign}) program that comes with the
484FORMS library (see module \module{fl} above).
Guido van Rossum5fdeeea1994-01-02 01:22:07 +0000485
486For now, see the file \file{flp.doc} in the Python library source
487directory for a description.
488
489XXX A complete description should be inserted here!