1 \section{Built-in Module
\sectcode{fl
}}
4 This module provides an interface to the FORMS Library by Mark
5 Overmars, version
2.0b. For more info about FORMS, write to
6 {\tt markov@cs.ruu.nl
}.
8 Most functions are literal translations of their C equivalents,
9 dropping the initial
\samp{fl_
} from their name. Constants used by the
10 library are defined in module
\code{FL
} described below.
12 The creation of objects is a little different in Python than in C:
13 instead of the `current form' maintained by the library to which new
14 FORMS objects are added, all functions that add a FORMS object to a
15 button are methods of the Python object representing the form.
16 Consequently, there are no Python equivalents for the C functions
17 \code{fl_addto_form
} and
\code{fl_end_form
}, and the equivalent of
18 \code{fl_bgn_form
} is called
\code{fl.make_form
}.
20 Watch out for the somewhat confusing terminology: FORMS uses the word
21 \dfn{object
} for the buttons, sliders etc. that you can place in a form.
22 In Python, `object' means any value. The Python interface to FORMS
23 introduces two new Python object types: form objects (representing an
24 entire form) and FORMS objects (representing one button, slider etc.).
25 Hopefully this isn't too confusing...
27 There are no `free objects' in the Python interface to FORMS, nor is
28 there an easy way to add object classes written in Python. The FORMS
29 interface to GL event handling is avaiable, though, so you can mix
30 FORMS with pure GL windows.
32 \strong{Please note:
} importing
\code{fl
} implies a call to the GL function
33 \code{foreground()
} and to the FORMS routine
\code{fl_init()
}.
35 \subsection{Functions defined in module
\sectcode{fl
}}
37 Module
\code{fl
} defines the following functions. For more information
38 about what they do, see the description of the equivalent C function
39 in the FORMS documentation:
41 \renewcommand{\indexsubitem}{(in module fl)
}
42 \begin{funcdesc
}{make_form
}{type\, width\, height
}
43 Create a form with given type, width and height. This returns a
44 \dfn{form
} object, whose methods are described below.
47 \begin{funcdesc
}{do_forms
}{}
48 The standard FORMS main loop. Returns a Python object representing
49 the FORMS object needing interaction, or the special value
53 \begin{funcdesc
}{check_forms
}{}
54 Check for FORMS events. Returns what
\code{do_forms
} above returns,
55 or
\code{None
} if there is no event that immediately needs
59 \begin{funcdesc
}{set_event_call_back
}{function
}
60 Set the event callback function.
63 \begin{funcdesc
}{set_graphics_mode
}{rgbmode\, doublebuffering
}
64 Set the graphics modes.
67 \begin{funcdesc
}{get_rgbmode
}{}
68 Return the current rgb mode. This is the value of the C global
69 variable
\code{fl_rgbmode
}.
72 \begin{funcdesc
}{show_message
}{str1\, str2\, str3
}
73 Show a dialog box with a three-line message and an OK button.
76 \begin{funcdesc
}{show_question
}{str1\, str2\, str3
}
77 Show a dialog box with a three-line message and YES and NO buttons.
78 It returns
\code{1} if the user pressed YES,
\code{0} if NO.
81 \begin{funcdesc
}{show_choice
}{str1\, str2\, str3\, but1
\optional{\, but2\,
83 Show a dialog box with a three-line message and up to three buttons.
84 It returns the number of the button clicked by the user
85 (
\code{1},
\code{2} or
\code{3}).
88 \begin{funcdesc
}{show_input
}{prompt\, default
}
89 Show a dialog box with a one-line prompt message and text field in
90 which the user can enter a string. The second argument is the default
91 input string. It returns the string value as edited by the user.
94 \begin{funcdesc
}{show_file_selector
}{message\, directory\, pattern\, default
}
95 Show a dialog box inm which the user can select a file. It returns
96 the absolute filename selected by the user, or
\code{None
} if the user
100 \begin{funcdesc
}{get_directory
}{}
101 \funcline{get_pattern
}{}
102 \funcline{get_filename
}{}
103 These functions return the directory, pattern and filename (the tail
104 part only) selected by the user in the last
\code{show_file_selector
}
108 \begin{funcdesc
}{qdevice
}{dev
}
109 \funcline{unqdevice
}{dev
}
110 \funcline{isqueued
}{dev
}
113 %\funcline{blkqread}{?}
115 \funcline{qenter
}{dev\, val
}
116 \funcline{get_mouse
}{}
117 \funcline{tie
}{button\, valuator1\, valuator2
}
118 These functions are the FORMS interfaces to the corresponding GL
119 functions. Use these if you want to handle some GL events yourself
120 when using
\code{fl.do_events
}. When a GL event is detected that
121 FORMS cannot handle,
\code{fl.do_forms()
} returns the special value
122 \code{FL.EVENT
} and you should call
\code{fl.qread()
} to read the
123 event from the queue. Don't use the equivalent GL functions!
126 \begin{funcdesc
}{color}{}
127 \funcline{mapcolor
}{}
128 \funcline{getmcolor
}{}
129 See the description in the FORMS documentation of
\code{fl_color
},
130 \code{fl_mapcolor
} and
\code{fl_getmcolor
}.
133 \subsection{Form object methods and data attributes
}
135 Form objects (returned by
\code{fl.make_form()
} above) have the
136 following methods. Each method corresponds to a C function whose name
137 is prefixed with
\samp{fl_
}; and whose first argument is a form
138 pointer; please refer to the official FORMS documentation for
141 All the
\samp{add_
{\rm \ldots}} functions return a Python object representing
142 the FORMS object. Methods of FORMS objects are described below. Most
143 kinds of FORMS object also have some methods specific to that kind;
144 these methods are listed here.
147 \renewcommand{\indexsubitem}{(form object method)
}
148 \begin{funcdesc
}{show_form
}{placement\, bordertype\, name
}
152 \begin{funcdesc
}{hide_form
}{}
156 \begin{funcdesc
}{redraw_form
}{}
160 \begin{funcdesc
}{set_form_position
}{x\, y
}
161 Set the form's position.
164 \begin{funcdesc
}{freeze_form
}{}
168 \begin{funcdesc
}{unfreeze_form
}{}
172 \begin{funcdesc
}{activate_form
}{}
176 \begin{funcdesc
}{deactivate_form
}{}
180 \begin{funcdesc
}{bgn_group
}{}
181 Begin a new group of objects; return a group object.
184 \begin{funcdesc
}{end_group
}{}
185 End the current group of objects.
188 \begin{funcdesc
}{find_first
}{}
189 Find the first object in the form.
192 \begin{funcdesc
}{find_last
}{}
193 Find the last object in the form.
198 \begin{funcdesc
}{add_box
}{type\, x\, y\, w\, h\, name
}
199 Add a box object to the form.
203 \begin{funcdesc
}{add_text
}{type\, x\, y\, w\, h\, name
}
204 Add a text object to the form.
208 %\begin{funcdesc}{add_bitmap}{type\, x\, y\, w\, h\, name}
209 %Add a bitmap object to the form.
212 \begin{funcdesc
}{add_clock
}{type\, x\, y\, w\, h\, name
}
213 Add a clock object to the form. \\
220 \begin{funcdesc
}{add_button
}{type\, x\, y\, w\, h\, name
}
221 Add a button object to the form. \\
227 \begin{funcdesc
}{add_lightbutton
}{type\, x\, y\, w\, h\, name
}
228 Add a lightbutton object to the form. \\
234 \begin{funcdesc
}{add_roundbutton
}{type\, x\, y\, w\, h\, name
}
235 Add a roundbutton object to the form. \\
243 \begin{funcdesc
}{add_slider
}{type\, x\, y\, w\, h\, name
}
244 Add a slider object to the form. \\
246 \code{set_slider_value
},
247 \code{get_slider_value
},
248 \code{set_slider_bounds
},
249 \code{get_slider_bounds
},
250 \code{set_slider_return
},
251 \code{set_slider_size
},
252 \code{set_slider_precision
},
253 \code{set_slider_step
}.
256 \begin{funcdesc
}{add_valslider
}{type\, x\, y\, w\, h\, name
}
257 Add a valslider object to the form. \\
259 \code{set_slider_value
},
260 \code{get_slider_value
},
261 \code{set_slider_bounds
},
262 \code{get_slider_bounds
},
263 \code{set_slider_return
},
264 \code{set_slider_size
},
265 \code{set_slider_precision
},
266 \code{set_slider_step
}.
269 \begin{funcdesc
}{add_dial
}{type\, x\, y\, w\, h\, name
}
270 Add a dial object to the form. \\
272 \code{set_dial_value
},
273 \code{get_dial_value
},
274 \code{set_dial_bounds
},
275 \code{get_dial_bounds
}.
278 \begin{funcdesc
}{add_positioner
}{type\, x\, y\, w\, h\, name
}
279 Add a positioner object to the form. \\
281 \code{set_positioner_xvalue
},
282 \code{set_positioner_yvalue
},
283 \code{set_positioner_xbounds
},
284 \code{set_positioner_ybounds
},
285 \code{get_positioner_xvalue
},
286 \code{get_positioner_yvalue
},
287 \code{get_positioner_xbounds
},
288 \code{get_positioner_ybounds
}.
291 \begin{funcdesc
}{add_counter
}{type\, x\, y\, w\, h\, name
}
292 Add a counter object to the form. \\
294 \code{set_counter_value
},
295 \code{get_counter_value
},
296 \code{set_counter_bounds
},
297 \code{set_counter_step
},
298 \code{set_counter_precision
},
299 \code{set_counter_return
}.
304 \begin{funcdesc
}{add_input
}{type\, x\, y\, w\, h\, name
}
305 Add a input object to the form. \\
309 \code{set_input_color
},
310 \code{set_input_return
}.
315 \begin{funcdesc
}{add_menu
}{type\, x\, y\, w\, h\, name
}
316 Add a menu object to the form. \\
323 \begin{funcdesc
}{add_choice
}{type\, x\, y\, w\, h\, name
}
324 Add a choice object to the form. \\
330 \code{replace_choice
},
331 \code{delete_choice
},
332 \code{get_choice_text
},
333 \code{set_choice_fontsize
},
334 \code{set_choice_fontstyle
}.
337 \begin{funcdesc
}{add_browser
}{type\, x\, y\, w\, h\, name
}
338 Add a browser object to the form. \\
340 \code{set_browser_topline
},
341 \code{clear_browser
},
342 \code{add_browser_line
},
343 \code{addto_browser
},
344 \code{insert_browser_line
},
345 \code{delete_browser_line
},
346 \code{replace_browser_line
},
347 \code{get_browser_line
},
349 \code{get_browser_maxline
},
350 \code{select_browser_line
},
351 \code{deselect_browser_line
},
352 \code{deselect_browser
},
353 \code{isselected_browser_line
},
355 \code{set_browser_fontsize
},
356 \code{set_browser_fontstyle
},
357 \code{set_browser_specialkey
}.
362 \begin{funcdesc
}{add_timer
}{type\, x\, y\, w\, h\, name
}
363 Add a timer object to the form. \\
370 Form objects have the following data attributes; see the FORMS
373 \begin{tableiii
}{|l|c|l|
}{code
}{Name
}{Type
}{Meaning
}
374 \lineiii{window
}{int (read-only)
}{GL window id
}
375 \lineiii{w
}{float
}{form width
}
376 \lineiii{h
}{float
}{form height
}
377 \lineiii{x
}{float
}{form x origin
}
378 \lineiii{y
}{float
}{form y origin
}
379 \lineiii{deactivated
}{int
}{nonzero if form is deactivated
}
380 \lineiii{visible
}{int
}{nonzero if form is visible
}
381 \lineiii{frozen
}{int
}{nonzero if form is frozen
}
382 \lineiii{doublebuf
}{int
}{nonzero if double buffering on
}
385 \subsection{FORMS object methods and data attributes
}
387 Besides methods specific to particular kinds of FORMS objects, all
388 FORMS objects also have the following methods:
390 \renewcommand{\indexsubitem}{(FORMS object method)
}
391 \begin{funcdesc
}{set_call_back
}{function\, argument
}
392 Set the object's callback function and argument. When the object
393 needs interaction, the callback function will be called with two
394 arguments: the object, and the callback argument. (FORMS objects
395 without a callback function are returned by
\code{fl.do_forms()
} or
396 \code{fl.check_forms()
} when they need interaction.) Call this method
397 without arguments to remove the callback function.
400 \begin{funcdesc
}{delete_object
}{}
404 \begin{funcdesc
}{show_object
}{}
408 \begin{funcdesc
}{hide_object
}{}
412 \begin{funcdesc
}{redraw_object
}{}
416 \begin{funcdesc
}{freeze_object
}{}
420 \begin{funcdesc
}{unfreeze_object
}{}
424 %\begin{funcdesc}{handle_object}{} XXX
427 %\begin{funcdesc}{handle_object_direct}{} XXX
430 FORMS objects have these data attributes; see the FORMS documentation:
432 \begin{tableiii
}{|l|c|l|
}{code
}{Name
}{Type
}{Meaning
}
433 \lineiii{objclass
}{int (read-only)
}{object class
}
434 \lineiii{type
}{int (read-only)
}{object type
}
435 \lineiii{boxtype
}{int
}{box type
}
436 \lineiii{x
}{float
}{x origin
}
437 \lineiii{y
}{float
}{y origin
}
438 \lineiii{w
}{float
}{width
}
439 \lineiii{h
}{float
}{height
}
440 \lineiii{col1
}{int
}{primary
color}
441 \lineiii{col2
}{int
}{secondary
color}
442 \lineiii{align
}{int
}{alignment
}
443 \lineiii{lcol
}{int
}{label
color}
444 \lineiii{lsize
}{float
}{label font size
}
445 \lineiii{label
}{string
}{label string
}
446 \lineiii{lstyle
}{int
}{label style
}
447 \lineiii{pushed
}{int (read-only)
}{(see FORMS docs)
}
448 \lineiii{focus
}{int (read-only)
}{(see FORMS docs)
}
449 \lineiii{belowmouse
}{int (read-only)
}{(see FORMS docs)
}
450 \lineiii{frozen
}{int (read-only)
}{(see FORMS docs)
}
451 \lineiii{active
}{int (read-only)
}{(see FORMS docs)
}
452 \lineiii{input
}{int (read-only)
}{(see FORMS docs)
}
453 \lineiii{visible
}{int (read-only)
}{(see FORMS docs)
}
454 \lineiii{radio
}{int (read-only)
}{(see FORMS docs)
}
455 \lineiii{automatic
}{int (read-only)
}{(see FORMS docs)
}
458 \section{Standard Module
\sectcode{FL
}}
459 \nodename{FL (uppercase)
}
462 This module defines symbolic constants needed to use the built-in
463 module
\code{fl
} (see above); they are equivalent to those defined in
464 the C header file
\file{<forms.h>
} except that the name prefix
465 \samp{FL_
} is omitted. Read the module source for a complete list of
466 the defined names. Suggested use:
468 \bcode\begin{verbatim
}
473 \section{Standard Module
\sectcode{flp
}}
476 This module defines functions that can read form definitions created
477 by the `form designer' (
\code{fdesign
}) program that comes with the
478 FORMS library (see module
\code{fl
} above).
480 For now, see the file
\file{flp.doc
} in the Python library source
481 directory for a description.
483 XXX A complete description should be inserted here!