source: trunk/essentials/dev-lang/python/Doc/lib/libfl.tex@ 3368

Last change on this file since 3368 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 15.2 KB
Line 
1\section{\module{fl} ---
2 FORMS library for graphical user interfaces}
3
4\declaremodule{builtin}{fl}
5 \platform{IRIX}
6\modulesynopsis{FORMS library for applications with graphical user
7 interfaces.}
8
9
10This module provides an interface to the FORMS Library\index{FORMS
11Library} by Mark Overmars\index{Overmars, Mark}. The source for the
12library can be retrieved by anonymous ftp from host
13\samp{ftp.cs.ruu.nl}, directory \file{SGI/FORMS}. It was last tested
14with version 2.0b.
15
16Most functions are literal translations of their C equivalents,
17dropping the initial \samp{fl_} from their name. Constants used by
18the library are defined in module \refmodule[fl-constants]{FL}
19described below.
20
21The creation of objects is a little different in Python than in C:
22instead of the `current form' maintained by the library to which new
23FORMS objects are added, all functions that add a FORMS object to a
24form are methods of the Python object representing the form.
25Consequently, there are no Python equivalents for the C functions
26\cfunction{fl_addto_form()} and \cfunction{fl_end_form()}, and the
27equivalent of \cfunction{fl_bgn_form()} is called
28\function{fl.make_form()}.
29
30Watch out for the somewhat confusing terminology: FORMS uses the word
31\dfn{object} for the buttons, sliders etc. that you can place in a form.
32In Python, `object' means any value. The Python interface to FORMS
33introduces two new Python object types: form objects (representing an
34entire form) and FORMS objects (representing one button, slider etc.).
35Hopefully this isn't too confusing.
36
37There are no `free objects' in the Python interface to FORMS, nor is
38there an easy way to add object classes written in Python. The FORMS
39interface to GL event handling is available, though, so you can mix
40FORMS with pure GL windows.
41
42\strong{Please note:} importing \module{fl} implies a call to the GL
43function \cfunction{foreground()} and to the FORMS routine
44\cfunction{fl_init()}.
45
46\subsection{Functions Defined in Module \module{fl}}
47\nodename{FL Functions}
48
49Module \module{fl} defines the following functions. For more
50information about what they do, see the description of the equivalent
51C function in the FORMS documentation:
52
53\begin{funcdesc}{make_form}{type, width, height}
54Create a form with given type, width and height. This returns a
55\dfn{form} object, whose methods are described below.
56\end{funcdesc}
57
58\begin{funcdesc}{do_forms}{}
59The standard FORMS main loop. Returns a Python object representing
60the FORMS object needing interaction, or the special value
61\constant{FL.EVENT}.
62\end{funcdesc}
63
64\begin{funcdesc}{check_forms}{}
65Check for FORMS events. Returns what \function{do_forms()} above
66returns, or \code{None} if there is no event that immediately needs
67interaction.
68\end{funcdesc}
69
70\begin{funcdesc}{set_event_call_back}{function}
71Set the event callback function.
72\end{funcdesc}
73
74\begin{funcdesc}{set_graphics_mode}{rgbmode, doublebuffering}
75Set the graphics modes.
76\end{funcdesc}
77
78\begin{funcdesc}{get_rgbmode}{}
79Return the current rgb mode. This is the value of the C global
80variable \cdata{fl_rgbmode}.
81\end{funcdesc}
82
83\begin{funcdesc}{show_message}{str1, str2, str3}
84Show a dialog box with a three-line message and an OK button.
85\end{funcdesc}
86
87\begin{funcdesc}{show_question}{str1, str2, str3}
88Show a dialog box with a three-line message and YES and NO buttons.
89It returns \code{1} if the user pressed YES, \code{0} if NO.
90\end{funcdesc}
91
92\begin{funcdesc}{show_choice}{str1, str2, str3, but1\optional{,
93 but2\optional{, but3}}}
94Show a dialog box with a three-line message and up to three buttons.
95It returns the number of the button clicked by the user
96(\code{1}, \code{2} or \code{3}).
97\end{funcdesc}
98
99\begin{funcdesc}{show_input}{prompt, default}
100Show a dialog box with a one-line prompt message and text field in
101which the user can enter a string. The second argument is the default
102input string. It returns the string value as edited by the user.
103\end{funcdesc}
104
105\begin{funcdesc}{show_file_selector}{message, directory, pattern, default}
106Show a dialog box in which the user can select a file. It returns
107the absolute filename selected by the user, or \code{None} if the user
108presses Cancel.
109\end{funcdesc}
110
111\begin{funcdesc}{get_directory}{}
112\funcline{get_pattern}{}
113\funcline{get_filename}{}
114These functions return the directory, pattern and filename (the tail
115part only) selected by the user in the last
116\function{show_file_selector()} call.
117\end{funcdesc}
118
119\begin{funcdesc}{qdevice}{dev}
120\funcline{unqdevice}{dev}
121\funcline{isqueued}{dev}
122\funcline{qtest}{}
123\funcline{qread}{}
124%\funcline{blkqread}{?}
125\funcline{qreset}{}
126\funcline{qenter}{dev, val}
127\funcline{get_mouse}{}
128\funcline{tie}{button, valuator1, valuator2}
129These functions are the FORMS interfaces to the corresponding GL
130functions. Use these if you want to handle some GL events yourself
131when using \function{fl.do_events()}. When a GL event is detected that
132FORMS cannot handle, \function{fl.do_forms()} returns the special value
133\constant{FL.EVENT} and you should call \function{fl.qread()} to read
134the event from the queue. Don't use the equivalent GL functions!
135\end{funcdesc}
136
137\begin{funcdesc}{color}{}
138\funcline{mapcolor}{}
139\funcline{getmcolor}{}
140See the description in the FORMS documentation of
141\cfunction{fl_color()}, \cfunction{fl_mapcolor()} and
142\cfunction{fl_getmcolor()}.
143\end{funcdesc}
144
145\subsection{Form Objects}
146\label{form-objects}
147
148Form objects (returned by \function{make_form()} above) have the
149following methods. Each method corresponds to a C function whose
150name is prefixed with \samp{fl_}; and whose first argument is a form
151pointer; please refer to the official FORMS documentation for
152descriptions.
153
154All the \method{add_*()} methods return a Python object representing
155the FORMS object. Methods of FORMS objects are described below. Most
156kinds of FORMS object also have some methods specific to that kind;
157these methods are listed here.
158
159\begin{flushleft}
160
161\begin{methoddesc}[form]{show_form}{placement, bordertype, name}
162 Show the form.
163\end{methoddesc}
164
165\begin{methoddesc}[form]{hide_form}{}
166 Hide the form.
167\end{methoddesc}
168
169\begin{methoddesc}[form]{redraw_form}{}
170 Redraw the form.
171\end{methoddesc}
172
173\begin{methoddesc}[form]{set_form_position}{x, y}
174Set the form's position.
175\end{methoddesc}
176
177\begin{methoddesc}[form]{freeze_form}{}
178Freeze the form.
179\end{methoddesc}
180
181\begin{methoddesc}[form]{unfreeze_form}{}
182 Unfreeze the form.
183\end{methoddesc}
184
185\begin{methoddesc}[form]{activate_form}{}
186 Activate the form.
187\end{methoddesc}
188
189\begin{methoddesc}[form]{deactivate_form}{}
190 Deactivate the form.
191\end{methoddesc}
192
193\begin{methoddesc}[form]{bgn_group}{}
194 Begin a new group of objects; return a group object.
195\end{methoddesc}
196
197\begin{methoddesc}[form]{end_group}{}
198 End the current group of objects.
199\end{methoddesc}
200
201\begin{methoddesc}[form]{find_first}{}
202 Find the first object in the form.
203\end{methoddesc}
204
205\begin{methoddesc}[form]{find_last}{}
206 Find the last object in the form.
207\end{methoddesc}