39.4. fl
— FORMS library for graphical user interfaces¶
2.6 版後已棄用: The fl
module has been removed in Python 3.
This module provides an interface to the FORMS Library by Mark Overmars. The
source for the library can be retrieved by anonymous FTP from host
ftp.cs.ruu.nl
, directory SGI/FORMS
. It was last tested with version
2.0b.
Most functions are literal translations of their C equivalents, dropping the
initial fl_
from their name. Constants used by the library are defined in
module FL
described below.
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 form are methods of the Python
object representing the form. Consequently, there are no Python equivalents for
the C functions fl_addto_form()
and fl_end_form()
, and the
equivalent of fl_bgn_form()
is called fl.make_form()
.
Watch out for the somewhat confusing terminology: FORMS uses the word 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.). Hopefully this isn’t too confusing.
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 interface to GL event handling is available, though, so you can mix FORMS with pure GL windows.
Please note: importing fl
implies a call to the GL function
foreground()
and to the FORMS routine fl_init()
.
39.4.1. Functions Defined in Module fl
¶
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:
-
fl.
make_form
(type, width, height)¶ Create a form with given type, width and height. This returns a form object, whose methods are described below.
-
fl.
do_forms
()¶ The standard FORMS main loop. Returns a Python object representing the FORMS object needing interaction, or the special value
FL.EVENT
.
-
fl.
check_forms
()¶ Check for FORMS events. Returns what
do_forms()
above returns, orNone
if there is no event that immediately needs interaction.
-
fl.
set_event_call_back
(function)¶ Set the event callback function.
-
fl.
set_graphics_mode
(rgbmode, doublebuffering)¶ Set the graphics modes.
-
fl.
get_rgbmode
()¶ Return the current rgb mode. This is the value of the C global variable
fl_rgbmode
.
-
fl.
show_message
(str1, str2, str3)¶ Show a dialog box with a three-line message and an OK button.
-
fl.
show_question
(str1, str2, str3)¶ Show a dialog box with a three-line message and YES and NO buttons. It returns
1
if the user pressed YES,0
if NO.
-
fl.
show_choice
(str1, str2, str3, but1[, but2[, but3]])¶ 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 (
1
,2
or3
).
-
fl.
show_input
(prompt, default)¶ 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.
-
fl.
show_file_selector
(message, directory, pattern, default)¶ Show a dialog box in which the user can select a file. It returns the absolute filename selected by the user, or
None
if the user presses Cancel.
-
fl.
get_directory
()¶ -
fl.
get_pattern
()¶ -
fl.
get_filename
()¶ These functions return the directory, pattern and filename (the tail part only) selected by the user in the last
show_file_selector()
call.
-
fl.
qdevice
(dev)¶ -
fl.
unqdevice
(dev)¶ -
fl.
isqueued
(dev)¶ -
fl.
qtest
()¶ -
fl.
qread
()¶ -
fl.
qreset
()¶ -
fl.
qenter
(dev, val)¶ -
fl.
get_mouse
()¶ -
fl.
tie
(button, valuator1, valuator2)¶ These functions are the FORMS interfaces to the corresponding GL functions. Use these if you want to handle some GL events yourself when using
fl.do_events()
. When a GL event is detected that FORMS cannot handle,fl.do_forms()
returns the special valueFL.EVENT
and you should callfl.qread()
to read the event from the queue. Don’t use the equivalent GL functions!
39.4.2. Form Objects¶
Form objects (returned by make_form()
above) have the following methods.
Each method corresponds to a C function whose name is prefixed with fl_
; and
whose first argument is a form pointer; please refer to the official FORMS
documentation for descriptions.
All the 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.
-
form.
show_form
(placement, bordertype, name)¶ Show the form.
-
form.
hide_form
()¶ Hide the form.
-
form.
redraw_form
()¶ Redraw the form.
-
form.
set_form_position
(x, y)¶ Set the form’s position.
-
form.
freeze_form
()¶ Freeze the form.
-
form.
unfreeze_form
()¶ Unfreeze the form.
-
form.
activate_form
()¶ Activate the form.
-
form.
deactivate_form
()¶ Deactivate the form.
-
form.
bgn_group
()¶ Begin a new group of objects; return a group object.
-
form.
end_group
()¶ End the current group of objects.
-
form.
find_first
()¶ Find the first object in the form.
-
form.
find_last
()¶ Find the last object in the form.
-
form.
add_box
(type, x, y, w, h, name)¶ Add a box object to the form. No extra methods.
-
form.
add_text
(type, x, y, w, h, name)¶ Add a text object to the form. No extra methods.
-
form.
add_clock
(type, x, y, w, h, name)¶ Add a clock object to the form. — Method:
get_clock()
.
Add a button object to the form. — Methods:
get_button()
,set_button()
.
Add a lightbutton object to the form. — Methods:
get_button()
,set_button()
.
Add a roundbutton object to the form. — Methods:
get_button()
,set_button()
.
-
form.
add_slider
(type, x, y, w, h, name)¶ Add a slider object to the form. — Methods:
set_slider_value()
,get_slider_value()
,set_slider_bounds()
,get_slider_bounds()
,set_slider_return()
,set_slider_size()
,set_slider_precision()
,set_slider_step()
.
-
form.
add_valslider
(type, x, y, w, h, name)¶ Add a valslider object to the form. — Methods:
set_slider_value()
,get_slider_value()
,set_slider_bounds()
,get_slider_bounds()
,set_slider_return()
,set_slider_size()
,set_slider_precision()
,set_slider_step()
.
-
form.
add_dial
(type, x, y, w, h, name)¶ Add a dial object to the form. — Methods:
set_dial_value()
,get_dial_value()
,set_dial_bounds()
,get_dial_bounds()
.
-
form.
add_positioner
(type, x, y, w, h, name)¶ Add a positioner object to the form. — Methods:
set_positioner_xvalue()
,set_positioner_yvalue()
,set_positioner_xbounds()
,set_positioner_ybounds()
,get_positioner_xvalue()
,get_positioner_yvalue()
,get_positioner_xbounds()
,get_positioner_ybounds()
.
-
form.
add_counter
(type, x, y, w, h, name)¶ Add a counter object to the form. — Methods:
set_counter_value()
,get_counter_value()
,set_counter_bounds()
,set_counter_step()
,set_counter_precision()
,set_counter_return()
.
-
form.
add_input
(type, x, y, w, h, name)¶ Add an input object to the form. — Methods:
set_input()
,get_input()
,set_input_color()
,set_input_return()
.
Add a menu object to the form. — Methods:
set_menu()
,get_menu()
,addto_menu()
.
-
form.
add_choice
(type, x, y, w, h, name)¶ Add a choice object to the form. — Methods:
set_choice()
,get_choice()
,clear_choice()
,addto_choice()
,replace_choice()
,delete_choice()
,get_choice_text()
,set_choice_fontsize()
,set_choice_fontstyle()
.
-
form.
add_browser
(type, x, y, w, h, name)¶ Add a browser object to the form. — Methods:
set_browser_topline()
,clear_browser()
,add_browser_line()
,addto_browser()
,insert_browser_line()
,delete_browser_line()
,replace_browser_line()
,get_browser_line()
,load_browser()
,get_browser_maxline()
,select_browser_line()
,deselect_browser_line()
,deselect_browser()
,isselected_browser_line()
,get_browser()
,set_browser_fontsize()
,set_browser_fontstyle()
,set_browser_specialkey()
.
-
form.
add_timer
(type, x, y, w, h, name)¶ Add a timer object to the form. — Methods:
set_timer()
,get_timer()
.
Form objects have the following data attributes; see the FORMS documentation:
Name |
C Type |
Meaning |
---|---|---|
|
int (read-only) |
GL window id |
|
float |
form width |
|
float |
form height |
|
float |
form x origin |
|
float |
form y origin |
|
int |
nonzero if form is deactivated |
|
int |
nonzero if form is visible |
|
int |
nonzero if form is frozen |
|
int |
nonzero if double buffering on |
39.4.3. FORMS Objects¶
Besides methods specific to particular kinds of FORMS objects, all FORMS objects also have the following methods:
-
FORMS object.set_call_back(function, argument)
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 without a callback function are returned by
fl.do_forms()
orfl.check_forms()
when they need interaction.) Call this method without arguments to remove the callback function.
-
FORMS object.delete_object()
Delete the object.
-
FORMS object.show_object()
Show the object.
-
FORMS object.hide_object()
Hide the object.
-
FORMS object.redraw_object()
Redraw the object.
-
FORMS object.freeze_object()
Freeze the object.
-
FORMS object.unfreeze_object()
Unfreeze the object.
FORMS objects have these data attributes; see the FORMS documentation:
Name |
C Type |
Meaning |
---|---|---|
|
int (read-only) |
object class |
int (read-only) |
object type |
|
|
int |
box type |
|
float |
x origin |
|
float |
y origin |
|
float |
width |
|
float |
height |
|
int |
primary color |
|
int |
secondary color |
|
int |
alignment |
|
int |
label color |
|
float |
label font size |
|
string |
label string |
|
int |
label style |
|
int (read-only) |
(see FORMS docs) |
|
int (read-only) |
(see FORMS docs) |
|
int (read-only) |
(see FORMS docs) |
|
int (read-only) |
(see FORMS docs) |
|
int (read-only) |
(see FORMS docs) |
int (read-only) |
(see FORMS docs) |
|
|
int (read-only) |
(see FORMS docs) |
|
int (read-only) |
(see FORMS docs) |
|
int (read-only) |
(see FORMS docs) |
39.5. FL
— Constants used with the fl
module¶
2.6 版後已棄用: The FL
module has been removed in Python 3.
This module defines symbolic constants needed to use the built-in module
fl
(see above); they are equivalent to those defined in the C header file
<forms.h>
except that the name prefix FL_
is omitted. Read the module
source for a complete list of the defined names. Suggested use:
import fl
from FL import *
39.6. flp
— Functions for loading stored FORMS designs¶
2.6 版後已棄用: The flp
module has been removed in Python 3.
This module defines functions that can read form definitions created by the
『form designer』 (fdesign) program that comes with the FORMS library
(see module fl
above).
For now, see the file flp.doc
in the Python library source directory for
a description.
XXX A complete description should be inserted here!