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