libfl.tex 15.1 KB
Newer Older
Fred Drake's avatar
Fred Drake committed
1 2
\section{\module{fl} ---
         FORMS library interface for GUI applications.}
3 4 5 6
\declaremodule{builtin}{fl}

\modulesynopsis{FORMS library interface for GUI applications.}

7

Fred Drake's avatar
Fred Drake committed
8 9 10 11 12
This module provides an interface to the FORMS Library\index{FORMS
Library} by Mark Overmars\index{Overmars, Mark}.  The source for the
library can be retrieved by anonymous ftp from host
\samp{ftp.cs.ruu.nl}, directory \file{SGI/FORMS}.  It was last tested
with version 2.0b.
13

14
Most functions are literal translations of their \C{} equivalents,
15
dropping the initial \samp{fl_} from their name.  Constants used by
16
the library are defined in module \module{FL} described below.
17 18 19 20

The creation of objects is a little different in Python than in C:
instead of the `current form' maintained by the library to which new
FORMS objects are added, all functions that add a FORMS object to a
21
form are methods of the Python object representing the form.
22
Consequently, there are no Python equivalents for the C functions
23 24 25
\cfunction{fl_addto_form()} and \cfunction{fl_end_form()}, and the
equivalent of \cfunction{fl_bgn_form()} is called
\function{fl.make_form()}.
26 27 28 29 30 31

Watch out for the somewhat confusing terminology: FORMS uses the word
\dfn{object} for the buttons, sliders etc. that you can place in a form.
In Python, `object' means any value.  The Python interface to FORMS
introduces two new Python object types: form objects (representing an
entire form) and FORMS objects (representing one button, slider etc.).
32
Hopefully this isn't too confusing.
33 34 35

There are no `free objects' in the Python interface to FORMS, nor is
there an easy way to add object classes written in Python.  The FORMS
36
interface to GL event handling is available, though, so you can mix
37 38
FORMS with pure GL windows.

39 40 41
\strong{Please note:} importing \module{fl} implies a call to the GL
function \cfunction{foreground()} and to the FORMS routine
\cfunction{fl_init()}.
42

43
\subsection{Functions Defined in Module \module{fl}}
44
\nodename{FL Functions}
45

46 47 48
Module \module{fl} defines the following functions.  For more
information about what they do, see the description of the equivalent
\C{} function in the FORMS documentation:
49

Fred Drake's avatar
Fred Drake committed
50
\begin{funcdesc}{make_form}{type, width, height}
51 52 53 54 55 56 57
Create a form with given type, width and height.  This returns a
\dfn{form} object, whose methods are described below.
\end{funcdesc}

\begin{funcdesc}{do_forms}{}
The standard FORMS main loop.  Returns a Python object representing
the FORMS object needing interaction, or the special value
58
\constant{FL.EVENT}.
59 60 61
\end{funcdesc}

\begin{funcdesc}{check_forms}{}
62 63
Check for FORMS events.  Returns what \function{do_forms()} above
returns, or \code{None} if there is no event that immediately needs
64 65 66 67 68 69 70
interaction.
\end{funcdesc}

\begin{funcdesc}{set_event_call_back}{function}
Set the event callback function.
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
71
\begin{funcdesc}{set_graphics_mode}{rgbmode, doublebuffering}
72 73 74 75
Set the graphics modes.
\end{funcdesc}

\begin{funcdesc}{get_rgbmode}{}
Fred Drake's avatar
Fred Drake committed
76
Return the current rgb mode.  This is the value of the \C{} global
77
variable \cdata{fl_rgbmode}.
78 79
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
80
\begin{funcdesc}{show_message}{str1, str2, str3}
81 82 83
Show a dialog box with a three-line message and an OK button.
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
84
\begin{funcdesc}{show_question}{str1, str2, str3}
85 86 87 88
Show a dialog box with a three-line message and YES and NO buttons.
It returns \code{1} if the user pressed YES, \code{0} if NO.
\end{funcdesc}

89 90
\begin{funcdesc}{show_choice}{str1, str2, str3, but1\optional{,
                              but2\optional{, but3}}}
91 92 93 94 95
Show a dialog box with a three-line message and up to three buttons.
It returns the number of the button clicked by the user
(\code{1}, \code{2} or \code{3}).
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
96
\begin{funcdesc}{show_input}{prompt, default}
97 98 99 100 101
Show a dialog box with a one-line prompt message and text field in
which the user can enter a string.  The second argument is the default
input string.  It returns the string value as edited by the user.
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
102
\begin{funcdesc}{show_file_selector}{message, directory, pattern, default}
103
Show a dialog box in which the user can select a file.  It returns
104 105 106 107 108 109 110 111
the absolute filename selected by the user, or \code{None} if the user
presses Cancel.
\end{funcdesc}

\begin{funcdesc}{get_directory}{}
\funcline{get_pattern}{}
\funcline{get_filename}{}
These functions return the directory, pattern and filename (the tail
112 113
part only) selected by the user in the last
\function{show_file_selector()} call.
114 115 116 117 118 119 120 121 122
\end{funcdesc}

\begin{funcdesc}{qdevice}{dev}
\funcline{unqdevice}{dev}
\funcline{isqueued}{dev}
\funcline{qtest}{}
\funcline{qread}{}
%\funcline{blkqread}{?}
\funcline{qreset}{}
Fred Drake's avatar
Fred Drake committed
123
\funcline{qenter}{dev, val}
124
\funcline{get_mouse}{}
Fred Drake's avatar
Fred Drake committed
125
\funcline{tie}{button, valuator1, valuator2}
126 127
These functions are the FORMS interfaces to the corresponding GL
functions.  Use these if you want to handle some GL events yourself
128 129 130 131
when using \function{fl.do_events()}.  When a GL event is detected that
FORMS cannot handle, \function{fl.do_forms()} returns the special value
\constant{FL.EVENT} and you should call \function{fl.qread()} to read
the event from the queue.  Don't use the equivalent GL functions!
132 133 134 135 136
\end{funcdesc}

\begin{funcdesc}{color}{}
\funcline{mapcolor}{}
\funcline{getmcolor}{}
137 138 139
See the description in the FORMS documentation of
\cfunction{fl_color()}, \cfunction{fl_mapcolor()} and
\cfunction{fl_getmcolor()}.
140 141
\end{funcdesc}

142
\subsection{Form Objects}
143
\label{form-objects}
144

145
Form objects (returned by \function{make_form()} above) have the
146 147
following methods.  Each method corresponds to a \C{} function whose
name is prefixed with \samp{fl_}; and whose first argument is a form
148 149 150
pointer; please refer to the official FORMS documentation for
descriptions.

151 152 153 154
All the \method{add_*()} methods return a Python object representing
the FORMS object.  Methods of FORMS objects are described below.  Most
kinds of FORMS object also have some methods specific to that kind;
these methods are listed here.
155 156

\begin{flushleft}
157 158

\begin{methoddesc}[form]{show_form}{placement, bordertype, name}
159
  Show the form.
160
\end{methoddesc}
161

162
\begin{methoddesc}[form]{hide_form}{}
163
  Hide the form.
164
\end{methoddesc}
165

166
\begin{methoddesc}[form]{redraw_form}{}
167
  Redraw the form.
168
\end{methoddesc}
169

170
\begin{methoddesc}[form]{set_form_position}{x, y}
171
Set the form's position.
172
\end{methoddesc}
173

174
\begin{methoddesc}[form]{freeze_form}{}
175
Freeze the form.
176
\end{methoddesc}
177

178
\begin{methoddesc}[form]{unfreeze_form}{}
179
  Unfreeze the form.
180
\end{methoddesc}
181

182
\begin{methoddesc}[form]{activate_form}{}
183
  Activate the form.
184
\end{methoddesc}
185

186
\begin{methoddesc}[form]{deactivate_form}{}
187
  Deactivate the form.
188
\end{methoddesc}
189

190
\begin{methoddesc}[form]{bgn_group}{}
191
  Begin a new group of objects; return a group object.
192
\end{methoddesc}
193

194
\begin{methoddesc}[form]{end_group}{}
195
  End the current group of objects.
196
\end{methoddesc}
197

198
\begin{methoddesc}[form]{find_first}{}
199
  Find the first object in the form.
200
\end{methoddesc}
201

202
\begin{methoddesc}[form]{find_last}{}
203
  Find the last object in the form.
204
\end{methoddesc}
205 206 207

%---

208
\begin{methoddesc}[form]{add_box}{type, x, y, w, h, name}
209 210
Add a box object to the form.
No extra methods.
211
\end{methoddesc}
212

213
\begin{methoddesc}[form]{add_text}{type, x, y, w, h, name}
214 215
Add a text object to the form.
No extra methods.
216
\end{methoddesc}
217

218
%\begin{methoddesc}[form]{add_bitmap}{type, x, y, w, h, name}
219
%Add a bitmap object to the form.
220
%\end{methoddesc}
221

222
\begin{methoddesc}[form]{add_clock}{type, x, y, w, h, name}
223 224
Add a clock object to the form. \\
Method:
225
\method{get_clock()}.
226
\end{methoddesc}
227 228 229

%---

230
\begin{methoddesc}[form]{add_button}{type, x, y, w, h,  name}
231 232
Add a button object to the form. \\
Methods:
233 234
\method{get_button()},
\method{set_button()}.
235
\end{methoddesc}
236

237
\begin{methoddesc}[form]{add_lightbutton}{type, x, y, w, h, name}
238 239
Add a lightbutton object to the form. \\
Methods:
240 241
\method{get_button()},
\method{set_button()}.
242
\end{methoddesc}
243

244
\begin{methoddesc}[form]{add_roundbutton}{type, x, y, w, h, name}
245 246
Add a roundbutton object to the form. \\
Methods:
247 248
\method{get_button()},
\method{set_button()}.
249
\end{methoddesc}
250 251 252

%---

253
\begin{methoddesc}[form]{add_slider}{type, x, y, w, h, name}
254 255
Add a slider object to the form. \\
Methods:
256 257 258 259 260 261 262 263
\method{set_slider_value()},
\method{get_slider_value()},
\method{set_slider_bounds()},
\method{get_slider_bounds()},
\method{set_slider_return()},
\method{set_slider_size()},
\method{set_slider_precision()},
\method{set_slider_step()}.
264
\end{methoddesc}
265

266
\begin{methoddesc}[form]{add_valslider}{type, x, y, w, h, name}
267 268
Add a valslider object to the form. \\
Methods:
269 270 271 272 273 274 275 276
\method{set_slider_value()},
\method{get_slider_value()},
\method{set_slider_bounds()},
\method{get_slider_bounds()},
\method{set_slider_return()},
\method{set_slider_size()},
\method{set_slider_precision()},
\method{set_slider_step()}.
277
\end{methoddesc}
278

279
\begin{methoddesc}[form]{add_dial}{type, x, y, w, h, name}
280 281
Add a dial object to the form. \\
Methods:
282 283 284 285
\method{set_dial_value()},
\method{get_dial_value()},
\method{set_dial_bounds()},
\method{get_dial_bounds()}.
286
\end{methoddesc}
287

288
\begin{methoddesc}[form]{add_positioner}{type, x, y, w, h, name}
289 290
Add a positioner object to the form. \\
Methods:
291 292 293 294 295 296 297 298
\method{set_positioner_xvalue()},
\method{set_positioner_yvalue()},
\method{set_positioner_xbounds()},
\method{set_positioner_ybounds()},
\method{get_positioner_xvalue()},
\method{get_positioner_yvalue()},
\method{get_positioner_xbounds()},
\method{get_positioner_ybounds()}.
299
\end{methoddesc}
300

301
\begin{methoddesc}[form]{add_counter}{type, x, y, w, h, name}
302 303
Add a counter object to the form. \\
Methods:
304 305 306 307 308 309
\method{set_counter_value()},
\method{get_counter_value()},
\method{set_counter_bounds()},
\method{set_counter_step()},
\method{set_counter_precision()},
\method{set_counter_return()}.
310
\end{methoddesc}
311 312 313

%---

314
\begin{methoddesc}[form]{add_input}{type, x, y, w, h, name}
315 316
Add a input object to the form. \\
Methods:
317 318 319 320
\method{set_input()},
\method{get_input()},
\method{set_input_color()},
\method{set_input_return()}.
321
\end{methoddesc}
322 323 324

%---

325
\begin{methoddesc}[form]{add_menu}{type, x, y, w, h, name}
326 327
Add a menu object to the form. \\
Methods:
328 329 330
\method{set_menu()},
\method{get_menu()},
\method{addto_menu()}.
331
\end{methoddesc}
332

333
\begin{methoddesc}[form]{add_choice}{type, x, y, w, h, name}
334 335
Add a choice object to the form. \\
Methods:
336 337 338 339 340 341 342 343 344
\method{set_choice()},
\method{get_choice()},
\method{clear_choice()},
\method{addto_choice()},
\method{replace_choice()},
\method{delete_choice()},
\method{get_choice_text()},
\method{set_choice_fontsize()},
\method{set_choice_fontstyle()}.
345
\end{methoddesc}
346

347
\begin{methoddesc}[form]{add_browser}{type, x, y, w, h, name}
348 349
Add a browser object to the form. \\
Methods:
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
\method{set_browser_topline()},
\method{clear_browser()},
\method{add_browser_line()},
\method{addto_browser()},
\method{insert_browser_line()},
\method{delete_browser_line()},
\method{replace_browser_line()},
\method{get_browser_line()},
\method{load_browser()},
\method{get_browser_maxline()},
\method{select_browser_line()},
\method{deselect_browser_line()},
\method{deselect_browser()},
\method{isselected_browser_line()},
\method{get_browser()},
\method{set_browser_fontsize()},
\method{set_browser_fontstyle()},
\method{set_browser_specialkey()}.
368
\end{methoddesc}
369 370 371

%---

372
\begin{methoddesc}[form]{add_timer}{type, x, y, w, h, name}
373 374
Add a timer object to the form. \\
Methods:
375 376
\method{set_timer()},
\method{get_timer()}.
377
\end{methoddesc}
378 379 380 381 382
\end{flushleft}

Form objects have the following data attributes; see the FORMS
documentation:

Fred Drake's avatar
Fred Drake committed
383
\begin{tableiii}{l|l|l}{member}{Name}{C Type}{Meaning}
384 385 386 387 388 389 390 391 392 393 394
  \lineiii{window}{int (read-only)}{GL window id}
  \lineiii{w}{float}{form width}
  \lineiii{h}{float}{form height}
  \lineiii{x}{float}{form x origin}
  \lineiii{y}{float}{form y origin}
  \lineiii{deactivated}{int}{nonzero if form is deactivated}
  \lineiii{visible}{int}{nonzero if form is visible}
  \lineiii{frozen}{int}{nonzero if form is frozen}
  \lineiii{doublebuf}{int}{nonzero if double buffering on}
\end{tableiii}

395
\subsection{FORMS Objects}
396
\label{forms-objects}
397 398 399 400

Besides methods specific to particular kinds of FORMS objects, all
FORMS objects also have the following methods:

401
\begin{methoddesc}[FORMS object]{set_call_back}{function, argument}
402 403 404
Set the object's callback function and argument.  When the object
needs interaction, the callback function will be called with two
arguments: the object, and the callback argument.  (FORMS objects
405 406 407
without a callback function are returned by \function{fl.do_forms()}
or \function{fl.check_forms()} when they need interaction.)  Call this
method without arguments to remove the callback function.
408
\end{methoddesc}
409

410
\begin{methoddesc}[FORMS object]{delete_object}{}
411
  Delete the object.
412
\end{methoddesc}
413

414
\begin{methoddesc}[FORMS object]{show_object}{}
415
  Show the object.
416
\end{methoddesc}
417

418
\begin{methoddesc}[FORMS object]{hide_object}{}
419
  Hide the object.
420
\end{methoddesc}
421

422
\begin{methoddesc}[FORMS object]{redraw_object}{}
423
  Redraw the object.
424
\end{methoddesc}
425

426
\begin{methoddesc}[FORMS object]{freeze_object}{}
427
  Freeze the object.
428
\end{methoddesc}
429

430
\begin{methoddesc}[FORMS object]{unfreeze_object}{}
431
  Unfreeze the object.
432
\end{methoddesc}
433

434 435
%\begin{methoddesc}[FORMS object]{handle_object}{} XXX
%\end{methoddesc}
436

437 438
%\begin{methoddesc}[FORMS object]{handle_object_direct}{} XXX
%\end{methoddesc}
439 440 441

FORMS objects have these data attributes; see the FORMS documentation:

Fred Drake's avatar
Fred Drake committed
442
\begin{tableiii}{l|l|l}{member}{Name}{C Type}{Meaning}
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
  \lineiii{objclass}{int (read-only)}{object class}
  \lineiii{type}{int (read-only)}{object type}
  \lineiii{boxtype}{int}{box type}
  \lineiii{x}{float}{x origin}
  \lineiii{y}{float}{y origin}
  \lineiii{w}{float}{width}
  \lineiii{h}{float}{height}
  \lineiii{col1}{int}{primary color}
  \lineiii{col2}{int}{secondary color}
  \lineiii{align}{int}{alignment}
  \lineiii{lcol}{int}{label color}
  \lineiii{lsize}{float}{label font size}
  \lineiii{label}{string}{label string}
  \lineiii{lstyle}{int}{label style}
  \lineiii{pushed}{int (read-only)}{(see FORMS docs)}
  \lineiii{focus}{int (read-only)}{(see FORMS docs)}
  \lineiii{belowmouse}{int (read-only)}{(see FORMS docs)}
  \lineiii{frozen}{int (read-only)}{(see FORMS docs)}
  \lineiii{active}{int (read-only)}{(see FORMS docs)}
  \lineiii{input}{int (read-only)}{(see FORMS docs)}
  \lineiii{visible}{int (read-only)}{(see FORMS docs)}
  \lineiii{radio}{int (read-only)}{(see FORMS docs)}
  \lineiii{automatic}{int (read-only)}{(see FORMS docs)}
\end{tableiii}

Fred Drake's avatar
Fred Drake committed
468 469
\section{\module{FL} ---
         Constants used with the \module{fl} module.}
470 471 472 473
\declaremodule{standard}{FL}

\modulesynopsis{Constants used with the \module{fl} module.}

474 475

This module defines symbolic constants needed to use the built-in
476 477
module \module{fl} (see above); they are equivalent to those defined in
the \C{} header file \code{<forms.h>} except that the name prefix
478 479 480
\samp{FL_} is omitted.  Read the module source for a complete list of
the defined names.  Suggested use:

481
\begin{verbatim}
482 483
import fl
from FL import *
484
\end{verbatim}
485

Fred Drake's avatar
Fred Drake committed
486 487
\section{\module{flp} ---
         Loading functions for stored FORMS designs.}
488 489 490 491
\declaremodule{standard}{flp}

\modulesynopsis{Loading functions for stored FORMS designs.}

492 493

This module defines functions that can read form definitions created
494 495
by the `form designer' (\program{fdesign}) program that comes with the
FORMS library (see module \module{fl} above).
496 497 498 499 500

For now, see the file \file{flp.doc} in the Python library source
directory for a description.

XXX A complete description should be inserted here!