/Doc/library/fl.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 523 lines · 326 code · 197 blank · 0 comment · 0 complexity · 7b5a6b25f1bac2e0ec8e84a70c98817a MD5 · raw file

  1. :mod:`fl` --- FORMS library for graphical user interfaces
  2. =========================================================
  3. .. module:: fl
  4. :platform: IRIX
  5. :synopsis: FORMS library for applications with graphical user interfaces.
  6. :deprecated:
  7. .. deprecated:: 2.6
  8. The :mod:`fl` module has been deprecated for removal in Python 3.0.
  9. .. index::
  10. single: FORMS Library
  11. single: Overmars, Mark
  12. This module provides an interface to the FORMS Library by Mark Overmars. The
  13. source for the library can be retrieved by anonymous ftp from host
  14. ``ftp.cs.ruu.nl``, directory :file:`SGI/FORMS`. It was last tested with version
  15. 2.0b.
  16. Most functions are literal translations of their C equivalents, dropping the
  17. initial ``fl_`` from their name. Constants used by the library are defined in
  18. module :mod:`FL` described below.
  19. The creation of objects is a little different in Python than in C: instead of
  20. the 'current form' maintained by the library to which new FORMS objects are
  21. added, all functions that add a FORMS object to a form are methods of the Python
  22. object representing the form. Consequently, there are no Python equivalents for
  23. the C functions :cfunc:`fl_addto_form` and :cfunc:`fl_end_form`, and the
  24. equivalent of :cfunc:`fl_bgn_form` is called :func:`fl.make_form`.
  25. Watch out for the somewhat confusing terminology: FORMS uses the word
  26. :dfn:`object` for the buttons, sliders etc. that you can place in a form. In
  27. Python, 'object' means any value. The Python interface to FORMS introduces two
  28. new Python object types: form objects (representing an entire form) and FORMS
  29. objects (representing one button, slider etc.). Hopefully this isn't too
  30. confusing.
  31. There are no 'free objects' in the Python interface to FORMS, nor is there an
  32. easy way to add object classes written in Python. The FORMS interface to GL
  33. event handling is available, though, so you can mix FORMS with pure GL windows.
  34. **Please note:** importing :mod:`fl` implies a call to the GL function
  35. :cfunc:`foreground` and to the FORMS routine :cfunc:`fl_init`.
  36. .. _fl-functions:
  37. Functions Defined in Module :mod:`fl`
  38. -------------------------------------
  39. Module :mod:`fl` defines the following functions. For more information about
  40. what they do, see the description of the equivalent C function in the FORMS
  41. documentation:
  42. .. function:: make_form(type, width, height)
  43. Create a form with given type, width and height. This returns a :dfn:`form`
  44. object, whose methods are described below.
  45. .. function:: do_forms()
  46. The standard FORMS main loop. Returns a Python object representing the FORMS
  47. object needing interaction, or the special value :const:`FL.EVENT`.
  48. .. function:: check_forms()
  49. Check for FORMS events. Returns what :func:`do_forms` above returns, or
  50. ``None`` if there is no event that immediately needs interaction.
  51. .. function:: set_event_call_back(function)
  52. Set the event callback function.
  53. .. function:: set_graphics_mode(rgbmode, doublebuffering)
  54. Set the graphics modes.
  55. .. function:: get_rgbmode()
  56. Return the current rgb mode. This is the value of the C global variable
  57. :cdata:`fl_rgbmode`.
  58. .. function:: show_message(str1, str2, str3)
  59. Show a dialog box with a three-line message and an OK button.
  60. .. function:: show_question(str1, str2, str3)
  61. Show a dialog box with a three-line message and YES and NO buttons. It returns
  62. ``1`` if the user pressed YES, ``0`` if NO.
  63. .. function:: show_choice(str1, str2, str3, but1[, but2[, but3]])
  64. Show a dialog box with a three-line message and up to three buttons. It returns
  65. the number of the button clicked by the user (``1``, ``2`` or ``3``).
  66. .. function:: show_input(prompt, default)
  67. Show a dialog box with a one-line prompt message and text field in which the
  68. user can enter a string. The second argument is the default input string. It
  69. returns the string value as edited by the user.
  70. .. function:: show_file_selector(message, directory, pattern, default)
  71. Show a dialog box in which the user can select a file. It returns the absolute
  72. filename selected by the user, or ``None`` if the user presses Cancel.
  73. .. function:: get_directory()
  74. get_pattern()
  75. get_filename()
  76. These functions return the directory, pattern and filename (the tail part only)
  77. selected by the user in the last :func:`show_file_selector` call.
  78. .. function:: qdevice(dev)
  79. unqdevice(dev)
  80. isqueued(dev)
  81. qtest()
  82. qread()
  83. qreset()
  84. qenter(dev, val)
  85. get_mouse()
  86. tie(button, valuator1, valuator2)
  87. These functions are the FORMS interfaces to the corresponding GL functions. Use
  88. these if you want to handle some GL events yourself when using
  89. :func:`fl.do_events`. When a GL event is detected that FORMS cannot handle,
  90. :func:`fl.do_forms` returns the special value :const:`FL.EVENT` and you should
  91. call :func:`fl.qread` to read the event from the queue. Don't use the
  92. equivalent GL functions!
  93. .. \funcline{blkqread}{?}
  94. .. function:: color()
  95. mapcolor()
  96. getmcolor()
  97. See the description in the FORMS documentation of :cfunc:`fl_color`,
  98. :cfunc:`fl_mapcolor` and :cfunc:`fl_getmcolor`.
  99. .. _form-objects:
  100. Form Objects
  101. ------------
  102. Form objects (returned by :func:`make_form` above) have the following methods.
  103. Each method corresponds to a C function whose name is prefixed with ``fl_``; and
  104. whose first argument is a form pointer; please refer to the official FORMS
  105. documentation for descriptions.
  106. All the :meth:`add_\*` methods return a Python object representing the FORMS
  107. object. Methods of FORMS objects are described below. Most kinds of FORMS
  108. object also have some methods specific to that kind; these methods are listed
  109. here.
  110. .. method:: form.show_form(placement, bordertype, name)
  111. Show the form.
  112. .. method:: form.hide_form()
  113. Hide the form.
  114. .. method:: form.redraw_form()
  115. Redraw the form.
  116. .. method:: form.set_form_position(x, y)
  117. Set the form's position.
  118. .. method:: form.freeze_form()
  119. Freeze the form.
  120. .. method:: form.unfreeze_form()
  121. Unfreeze the form.
  122. .. method:: form.activate_form()
  123. Activate the form.
  124. .. method:: form.deactivate_form()
  125. Deactivate the form.
  126. .. method:: form.bgn_group()
  127. Begin a new group of objects; return a group object.
  128. .. method:: form.end_group()
  129. End the current group of objects.
  130. .. method:: form.find_first()
  131. Find the first object in the form.
  132. .. method:: form.find_last()
  133. Find the last object in the form.
  134. .. method:: form.add_box(type, x, y, w, h, name)
  135. Add a box object to the form. No extra methods.
  136. .. method:: form.add_text(type, x, y, w, h, name)
  137. Add a text object to the form. No extra methods.
  138. .. \begin{methoddesc}[form]{add_bitmap}{type, x, y, w, h, name}
  139. .. Add a bitmap object to the form.
  140. .. \end{methoddesc}
  141. .. method:: form.add_clock(type, x, y, w, h, name)
  142. Add a clock object to the form. --- Method: :meth:`get_clock`.
  143. .. method:: form.add_button(type, x, y, w, h, name)
  144. Add a button object to the form. --- Methods: :meth:`get_button`,
  145. :meth:`set_button`.
  146. .. method:: form.add_lightbutton(type, x, y, w, h, name)
  147. Add a lightbutton object to the form. --- Methods: :meth:`get_button`,
  148. :meth:`set_button`.
  149. .. method:: form.add_roundbutton(type, x, y, w, h, name)
  150. Add a roundbutton object to the form. --- Methods: :meth:`get_button`,
  151. :meth:`set_button`.
  152. .. method:: form.add_slider(type, x, y, w, h, name)
  153. Add a slider object to the form. --- Methods: :meth:`set_slider_value`,
  154. :meth:`get_slider_value`, :meth:`set_slider_bounds`, :meth:`get_slider_bounds`,
  155. :meth:`set_slider_return`, :meth:`set_slider_size`,
  156. :meth:`set_slider_precision`, :meth:`set_slider_step`.
  157. .. method:: form.add_valslider(type, x, y, w, h, name)
  158. Add a valslider object to the form. --- Methods: :meth:`set_slider_value`,
  159. :meth:`get_slider_value`, :meth:`set_slider_bounds`, :meth:`get_slider_bounds`,
  160. :meth:`set_slider_return`, :meth:`set_slider_size`,
  161. :meth:`set_slider_precision`, :meth:`set_slider_step`.
  162. .. method:: form.add_dial(type, x, y, w, h, name)
  163. Add a dial object to the form. --- Methods: :meth:`set_dial_value`,
  164. :meth:`get_dial_value`, :meth:`set_dial_bounds`, :meth:`get_dial_bounds`.
  165. .. method:: form.add_positioner(type, x, y, w, h, name)
  166. Add a positioner object to the form. --- Methods:
  167. :meth:`set_positioner_xvalue`, :meth:`set_positioner_yvalue`,
  168. :meth:`set_positioner_xbounds`, :meth:`set_positioner_ybounds`,
  169. :meth:`get_positioner_xvalue`, :meth:`get_positioner_yvalue`,
  170. :meth:`get_positioner_xbounds`, :meth:`get_positioner_ybounds`.
  171. .. method:: form.add_counter(type, x, y, w, h, name)
  172. Add a counter object to the form. --- Methods: :meth:`set_counter_value`,
  173. :meth:`get_counter_value`, :meth:`set_counter_bounds`, :meth:`set_counter_step`,
  174. :meth:`set_counter_precision`, :meth:`set_counter_return`.
  175. .. method:: form.add_input(type, x, y, w, h, name)
  176. Add a input object to the form. --- Methods: :meth:`set_input`,
  177. :meth:`get_input`, :meth:`set_input_color`, :meth:`set_input_return`.
  178. .. method:: form.add_menu(type, x, y, w, h, name)
  179. Add a menu object to the form. --- Methods: :meth:`set_menu`,
  180. :meth:`get_menu`, :meth:`addto_menu`.
  181. .. method:: form.add_choice(type, x, y, w, h, name)
  182. Add a choice object to the form. --- Methods: :meth:`set_choice`,
  183. :meth:`get_choice`, :meth:`clear_choice`, :meth:`addto_choice`,
  184. :meth:`replace_choice`, :meth:`delete_choice`, :meth:`get_choice_text`,
  185. :meth:`set_choice_fontsize`, :meth:`set_choice_fontstyle`.
  186. .. method:: form.add_browser(type, x, y, w, h, name)
  187. Add a browser object to the form. --- Methods: :meth:`set_browser_topline`,
  188. :meth:`clear_browser`, :meth:`add_browser_line`, :meth:`addto_browser`,
  189. :meth:`insert_browser_line`, :meth:`delete_browser_line`,
  190. :meth:`replace_browser_line`, :meth:`get_browser_line`, :meth:`load_browser`,
  191. :meth:`get_browser_maxline`, :meth:`select_browser_line`,
  192. :meth:`deselect_browser_line`, :meth:`deselect_browser`,
  193. :meth:`isselected_browser_line`, :meth:`get_browser`,
  194. :meth:`set_browser_fontsize`, :meth:`set_browser_fontstyle`,
  195. :meth:`set_browser_specialkey`.
  196. .. method:: form.add_timer(type, x, y, w, h, name)
  197. Add a timer object to the form. --- Methods: :meth:`set_timer`,
  198. :meth:`get_timer`.
  199. Form objects have the following data attributes; see the FORMS documentation:
  200. +---------------------+-----------------+--------------------------------+
  201. | Name | C Type | Meaning |
  202. +=====================+=================+================================+
  203. | :attr:`window` | int (read-only) | GL window id |
  204. +---------------------+-----------------+--------------------------------+
  205. | :attr:`w` | float | form width |
  206. +---------------------+-----------------+--------------------------------+
  207. | :attr:`h` | float | form height |
  208. +---------------------+-----------------+--------------------------------+
  209. | :attr:`x` | float | form x origin |
  210. +---------------------+-----------------+--------------------------------+
  211. | :attr:`y` | float | form y origin |
  212. +---------------------+-----------------+--------------------------------+
  213. | :attr:`deactivated` | int | nonzero if form is deactivated |
  214. +---------------------+-----------------+--------------------------------+
  215. | :attr:`visible` | int | nonzero if form is visible |
  216. +---------------------+-----------------+--------------------------------+
  217. | :attr:`frozen` | int | nonzero if form is frozen |
  218. +---------------------+-----------------+--------------------------------+
  219. | :attr:`doublebuf` | int | nonzero if double buffering on |
  220. +---------------------+-----------------+--------------------------------+
  221. .. _forms-objects:
  222. FORMS Objects
  223. -------------
  224. Besides methods specific to particular kinds of FORMS objects, all FORMS objects
  225. also have the following methods:
  226. .. method:: FORMS object.set_call_back(function, argument)
  227. Set the object's callback function and argument. When the object needs
  228. interaction, the callback function will be called with two arguments: the
  229. object, and the callback argument. (FORMS objects without a callback function
  230. are returned by :func:`fl.do_forms` or :func:`fl.check_forms` when they need
  231. interaction.) Call this method without arguments to remove the callback
  232. function.
  233. .. method:: FORMS object.delete_object()
  234. Delete the object.
  235. .. method:: FORMS object.show_object()
  236. Show the object.
  237. .. method:: FORMS object.hide_object()
  238. Hide the object.
  239. .. method:: FORMS object.redraw_object()
  240. Redraw the object.
  241. .. method:: FORMS object.freeze_object()
  242. Freeze the object.
  243. .. method:: FORMS object.unfreeze_object()
  244. Unfreeze the object.
  245. FORMS objects have these data attributes; see the FORMS documentation:
  246. .. \begin{methoddesc}[FORMS object]{handle_object}{} XXX
  247. .. \end{methoddesc}
  248. .. \begin{methoddesc}[FORMS object]{handle_object_direct}{} XXX
  249. .. \end{methoddesc}
  250. +--------------------+-----------------+------------------+
  251. | Name | C Type | Meaning |
  252. +====================+=================+==================+
  253. | :attr:`objclass` | int (read-only) | object class |
  254. +--------------------+-----------------+------------------+
  255. | :attr:`type` | int (read-only) | object type |
  256. +--------------------+-----------------+------------------+
  257. | :attr:`boxtype` | int | box type |
  258. +--------------------+-----------------+------------------+
  259. | :attr:`x` | float | x origin |
  260. +--------------------+-----------------+------------------+
  261. | :attr:`y` | float | y origin |
  262. +--------------------+-----------------+------------------+
  263. | :attr:`w` | float | width |
  264. +--------------------+-----------------+------------------+
  265. | :attr:`h` | float | height |
  266. +--------------------+-----------------+------------------+
  267. | :attr:`col1` | int | primary color |
  268. +--------------------+-----------------+------------------+
  269. | :attr:`col2` | int | secondary color |
  270. +--------------------+-----------------+------------------+
  271. | :attr:`align` | int | alignment |
  272. +--------------------+-----------------+------------------+
  273. | :attr:`lcol` | int | label color |
  274. +--------------------+-----------------+------------------+
  275. | :attr:`lsize` | float | label font size |
  276. +--------------------+-----------------+------------------+
  277. | :attr:`label` | string | label string |
  278. +--------------------+-----------------+------------------+
  279. | :attr:`lstyle` | int | label style |
  280. +--------------------+-----------------+------------------+
  281. | :attr:`pushed` | int (read-only) | (see FORMS docs) |
  282. +--------------------+-----------------+------------------+
  283. | :attr:`focus` | int (read-only) | (see FORMS docs) |
  284. +--------------------+-----------------+------------------+
  285. | :attr:`belowmouse` | int (read-only) | (see FORMS docs) |
  286. +--------------------+-----------------+------------------+
  287. | :attr:`frozen` | int (read-only) | (see FORMS docs) |
  288. +--------------------+-----------------+------------------+
  289. | :attr:`active` | int (read-only) | (see FORMS docs) |
  290. +--------------------+-----------------+------------------+
  291. | :attr:`input` | int (read-only) | (see FORMS docs) |
  292. +--------------------+-----------------+------------------+
  293. | :attr:`visible` | int (read-only) | (see FORMS docs) |
  294. +--------------------+-----------------+------------------+
  295. | :attr:`radio` | int (read-only) | (see FORMS docs) |
  296. +--------------------+-----------------+------------------+
  297. | :attr:`automatic` | int (read-only) | (see FORMS docs) |
  298. +--------------------+-----------------+------------------+
  299. :mod:`FL` --- Constants used with the :mod:`fl` module
  300. ======================================================
  301. .. module:: FL
  302. :platform: IRIX
  303. :synopsis: Constants used with the fl module.
  304. :deprecated:
  305. .. deprecated:: 2.6
  306. The :mod:`FL` module has been deprecated for removal in Python 3.0.
  307. This module defines symbolic constants needed to use the built-in module
  308. :mod:`fl` (see above); they are equivalent to those defined in the C header file
  309. ``<forms.h>`` except that the name prefix ``FL_`` is omitted. Read the module
  310. source for a complete list of the defined names. Suggested use::
  311. import fl
  312. from FL import *
  313. :mod:`flp` --- Functions for loading stored FORMS designs
  314. =========================================================
  315. .. module:: flp
  316. :platform: IRIX
  317. :synopsis: Functions for loading stored FORMS designs.
  318. :deprecated:
  319. .. deprecated:: 2.6
  320. The :mod:`flp` module has been deprecated for removal in Python 3.0.
  321. This module defines functions that can read form definitions created by the
  322. 'form designer' (:program:`fdesign`) program that comes with the FORMS library
  323. (see module :mod:`fl` above).
  324. For now, see the file :file:`flp.doc` in the Python library source directory for
  325. a description.
  326. XXX A complete description should be inserted here!