home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Other Langs
/
python
/
emacs-info
/
python-lib.info-4
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
GNU Info File
|
1994-04-01
|
49.5 KB
|
1,377 lines
|
[
TEXT/R*ch
]
This is Info file python-lib.info, produced by Makeinfo-1.55 from the
input file lib.texi.
This file describes the built-in types, exceptions and functions and the
standard modules that come with the Python system. It assumes basic
knowledge about the Python language. For an informal introduction to
the language, see the Python Tutorial. The Python Reference Manual
gives a more formal definition of the language. (These manuals are not
yet available in INFO or Texinfo format.)
Copyright (C) 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR
ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
File: python-lib.info, Node: Functions Defined in Module stdwin, Next: Window Object, Prev: stdwin, Up: stdwin
Functions Defined in Module `stdwin'
------------------------------------
The following functions are defined in the `stdwin' module:
- function of module stdwin: open (TITLE)
Open a new window whose initial title is given by the string
argument. Return a window object; window object methods are
described below.(1)
- function of module stdwin: getevent ()
Wait for and return the next event. An event is returned as a
triple: the first element is the event type, a small integer; the
second element is the window object to which the event applies, or
`None' if it applies to no window in particular; the third element
is type-dependent. Names for event types and command codes are
defined in the standard module `stdwinevent'.
- function of module stdwin: pollevent ()
Return the next event, if one is immediately available. If no
event is available, return `()'.
- function of module stdwin: getactive ()
Return the window that is currently active, or `None' if no window
is currently active. (This can be emulated by monitoring
WE_ACTIVATE and WE_DEACTIVATE events.)
- function of module stdwin: listfontnames (PATTERN)
Return the list of font names in the system that match the pattern
(a string). The pattern should normally be `'*''; returns all
available fonts. If the underlying window system is X11, other
patterns follow the standard X11 font selection syntax (as used
e.g. in resource definitions), i.e. the wildcard character `'*''
matches any sequence of characters (including none) and `'?''
matches any single character.
- function of module stdwin: setdefscrollbars (HFLAG, VFLAG)
Set the flags controlling whether subsequently opened windows will
have horizontal and/or vertical scroll bars.
- function of module stdwin: setdefwinpos (H, V)
Set the default window position for windows opened subsequently.
- function of module stdwin: setdefwinsize (WIDTH, HEIGHT)
Set the default window size for windows opened subsequently.
- function of module stdwin: getdefscrollbars ()
Return the flags controlling whether subsequently opened windows
will have horizontal and/or vertical scroll bars.
- function of module stdwin: getdefwinpos ()
Return the default window position for windows opened subsequently.
- function of module stdwin: getdefwinsize ()
Return the default window size for windows opened subsequently.
- function of module stdwin: getscrsize ()
Return the screen size in pixels.
- function of module stdwin: getscrmm ()
Return the screen size in millimeters.
- function of module stdwin: fetchcolor (COLORNAME)
Return the pixel value corresponding to the given color name.
Return the default foreground color for unknown color names.
Hint: the following code tests wheter you are on a machine that
supports more than two colors:
if stdwin.fetchcolor('black') <> \
stdwin.fetchcolor('red') <> \
stdwin.fetchcolor('white'):
print 'color machine'
else:
print 'monochrome machine'
- function of module stdwin: setfgcolor (PIXEL)
Set the default foreground color. This will become the default
foreground color of windows opened subsequently, including dialogs.
- function of module stdwin: setbgcolor (PIXEL)
Set the default background color. This will become the default
background color of windows opened subsequently, including dialogs.
- function of module stdwin: getfgcolor ()
Return the pixel value of the current default foreground color.
- function of module stdwin: getbgcolor ()
Return the pixel value of the current default background color.
- function of module stdwin: setfont (FONTNAME)
Set the current default font. This will become the default font
for windows opened subsequently, and is also used by the text
measuring functions `textwidth', `textbreak', `lineheight' and
`baseline' below. This accepts two more optional parameters, size
and style: Size is the font size (in `points'). Style is a single
character specifying the style, as follows: `'b'' = bold, `'i'' =
italic, `'o'' = bold + italic, `'u'' = underline; default style is
roman. Size and style are ignored under X11 but used on the
Macintosh. (Sorry for all this complexity -- a more uniform
interface is being designed.)
- function of module stdwin: menucreate (TITLE)
Create a menu object referring to a global menu (a menu that
appears in all windows). Methods of menu objects are described
below. Note: normally, menus are created locally; see the window
method `menucreate' below. *Warning:* the menu only appears in a
window as long as the object returned by this call exists.
- function of module stdwin: newbitmap (WIDTH, HEIGHT)
Create a new bitmap object of the given dimensions. Methods of
bitmap objects are described below.
- function of module stdwin: fleep ()
Cause a beep or bell (or perhaps a `visual bell' or flash, hence
the name).
- function of module stdwin: message (STRING)
Display a dialog box containing the string. The user must click
OK before the function returns.
- function of module stdwin: askync (PROMPT, DEFAULT)
Display a dialog that prompts the user to answer a question with
yes or no. Return 0 for no, 1 for yes. If the user hits the
Return key, the default (which must be 0 or 1) is returned. If
the user cancels the dialog, the `KeyboardInterrupt' exception is
raised.
- function of module stdwin: askstr (PROMPT, DEFAULT)
Display a dialog that prompts the user for a string. If the user
hits the Return key, the default string is returned. If the user
cancels the dialog, the `KeyboardInterrupt' exception is raised.
- function of module stdwin: askfile (PROMPT, DEFAULT, NEW)
Ask the user to specify a filename. If NEW is zero it must be an
existing file; otherwise, it must be a new file. If the user
cancels the dialog, the `KeyboardInterrupt' exception is raised.
- function of module stdwin: setcutbuffer (I, STRING)
Store the string in the system's cut buffer number I, where it can
be found (for pasting) by other applications. On X11, there are 8
cut buffers (numbered 0..7). Cut buffer number 0 is the
`clipboard' on the Macintosh.
- function of module stdwin: getcutbuffer (I)
Return the contents of the system's cut buffer number I.
- function of module stdwin: rotatecutbuffers (N)
On X11, rotate the 8 cut buffers by N. Ignored on the Macintosh.
- function of module stdwin: getselection (I)
Return X11 selection number I. Selections are not cut buffers.
Selection numbers are defined in module `stdwinevents'. Selection
`WS_PRIMARY' is the "primary" selection (used by xterm, for
instance); selection `WS_SECONDARY' is the "secondary" selection;
selection `WS_CLIPBOARD' is the "clipboard" selection (used by
xclipboard). On the Macintosh, this always returns an empty
string.
- function of module stdwin: resetselection (I)
Reset selection number I, if this process owns it. (See window
method `setselection()').
- function of module stdwin: baseline ()
Return the baseline of the current font (defined by STDWIN as the
vertical distance between the baseline and the top of the
characters).
- function of module stdwin: lineheight ()
Return the total line height of the current font.
- function of module stdwin: textbreak (STR, WIDTH)
Return the number of characters of the string that fit into a
space of WIDTH bits wide when drawn in the curent font.
- function of module stdwin: textwidth (STR)
Return the width in bits of the string when drawn in the current
font.
- function of module stdwin: connectionnumber ()
- function of module stdwin: fileno ()
(X11 under UNIX only) Return the "connection number" used by the
underlying X11 implementation. (This is normally the file number
of the socket.) Both functions return the same value;
`connectionnumber()' is named after the corresponding function in
X11 and STDWIN, while `fileno()' makes it possible to use the
`stdwin' module as a "file" object parameter to `select.select()'.
Note that if `select()' implies that input is possible on
`stdwin', this does not guarantee that an event is ready -- it may
be some internal communication going on between the X server and
the client library. Thus, you should call `stdwin.pollevent()'
until it returns `None' to check for events if you don't want your
program to block. Because of internal buffering in X11, it is
also possible that `stdwin.pollevent()' returns an event while
`select()' does not find `stdwin' to be ready, so you should read
any pending events with `stdwin.pollevent()' until it returns
`None' before entering a blocking `select()' call.
---------- Footnotes ----------
(1) The Python version of STDWIN does not support draw procedures; all
drawing requests are reported as draw events.
File: python-lib.info, Node: Window Object, Next: Drawing Object, Prev: Functions Defined in Module stdwin, Up: stdwin
Window Object Methods
---------------------
Window objects are created by `stdwin.open()'. They are closed by
their `close()' method or when they are garbage-collected. Window
objects have the following methods:
- Method on window: begindrawing ()
Return a drawing object, whose methods (described below) allow
drawing in the window.
- Method on window: change (RECT)
Invalidate the given rectangle; this may cause a draw event.
- Method on window: gettitle ()
Returns the window's title string.
- Method on window: getdocsize ()
Return a pair of integers giving the size of the document as set by
`setdocsize()'.
- Method on window: getorigin ()
Return a pair of integers giving the origin of the window with
respect to the document.
- Method on window: gettitle ()
Return the window's title string.
- Method on window: getwinsize ()
Return a pair of integers giving the size of the window.
- Method on window: getwinpos ()
Return a pair of integers giving the position of the window's upper
left corner (relative to the upper left corner of the screen).
- Method on window: menucreate (TITLE)
Create a menu object referring to a local menu (a menu that appears
only in this window). Methods of menu objects are described below.
Warning: the menu only appears as long as the object returned by
this call exists.
- Method on window: scroll (RECT, POINT)
Scroll the given rectangle by the vector given by the point.
- Method on window: setdocsize (POINT)
Set the size of the drawing document.
- Method on window: setorigin (POINT)
Move the origin of the window (its upper left corner) to the given
point in the document.
- Method on window: setselection (I, STR)
Attempt to set X11 selection number I to the string STR. (See
stdwin method `getselection()' for the meaning of I.) Return true
if it succeeds. If succeeds, the window "owns" the selection
until (a) another applications takes ownership of the selection; or
(b) the window is deleted; or (c) the application clears ownership
by calling `stdwin.resetselection(I)'. When another application
takes ownership of the selection, a `WE_LOST_SEL' event is
received for no particular window and with the selection number as
detail. Ignored on the Macintosh.
- Method on window: settimer (DSECS)
Schedule a timer event for the window in `DSECS/10' seconds.
- Method on window: settitle (TITLE)
Set the window's title string.
- Method on window: setwincursor (NAME)
Set the window cursor to a cursor of the given name. It raises the
`RuntimeError' exception if no cursor of the given name exists.
Suitable names include `'ibeam'', `'arrow'', `'cross'', `'watch''
and `'plus''. On X11, there are many more (see
`<X11/cursorfont.h>').
- Method on window: setwinpos (H, V)
Set the the position of the window's upper left corner (relative to
the upper left corner of the screen).
- Method on window: setwinsize (WIDTH, HEIGHT)
Set the window's size.
- Method on window: show (RECT)
Try to ensure that the given rectangle of the document is visible
in the window.
- Method on window: textcreate (RECT)
Create a text-edit object in the document at the given rectangle.
Methods of text-edit objects are described below.
- Method on window: setactive ()
Attempt to make this window the active window. If successful, this
will generate a WE_ACTIVATE event (and a WE_DEACTIVATE event in
case another window in this application became inactive).
- Method on window: close ()
Discard the window object. It should not be used again.
File: python-lib.info, Node: Drawing Object, Next: Menu Object, Prev: Window Object, Up: stdwin
Drawing Object Methods
----------------------
Drawing objects are created exclusively by the window method
`begindrawing()'. Only one drawing object can exist at any given time;
the drawing object must be deleted to finish drawing. No drawing
object may exist when `stdwin.getevent()' is called. Drawing objects
have the following methods:
- Method on drawing: box (RECT)
Draw a box just inside a rectangle.
- Method on drawing: circle (CENTER, RADIUS)
Draw a circle with given center point and radius.
- Method on drawing: elarc (CENTER, (RH, RV), (A1, A2))
Draw an elliptical arc with given center point. `(RH, RV)' gives
the half sizes of the horizontal and vertical radii. `(A1, A2)'
gives the angles (in degrees) of the begin and end points. 0
degrees is at 3 o'clock, 90 degrees is at 12 o'clock.
- Method on drawing: erase (RECT)
Erase a rectangle.
- Method on drawing: fillcircle (CENTER, RADIUS)
Draw a filled circle with given center point and radius.
- Method on drawing: fillelarc (CENTER, (RH, RV), (A1, A2))
Draw a filled elliptical arc; arguments as for `elarc'.
- Method on drawing: fillpoly (POINTS)
Draw a filled polygon given by a list (or tuple) of points.
- Method on drawing: invert (RECT)
Invert a rectangle.
- Method on drawing: line (P1, P2)
Draw a line from point P1 to P2.
- Method on drawing: paint (RECT)
Fill a rectangle.
- Method on drawing: poly (POINTS)
Draw the lines connecting the given list (or tuple) of points.
- Method on drawing: shade (RECT, PERCENT)
Fill a rectangle with a shading pattern that is about PERCENT
percent filled.
- Method on drawing: text (P, STR)
Draw a string starting at point p (the point specifies the top
left coordinate of the string).
- Method on drawing: xorcircle (CENTER, RADIUS)
- Method on drawing: xorelarc (CENTER, (RH, RV), (A1, A2))
- Method on drawing: xorline (P1, P2)
- Method on drawing: xorpoly (POINTS)
Draw a circle, an elliptical arc, a line or a polygon,
respectively, in XOR mode.
- Method on drawing: setfgcolor ()
- Method on drawing: setbgcolor ()
- Method on drawing: getfgcolor ()
- Method on drawing: getbgcolor ()
These functions are similar to the corresponding functions
described above for the `stdwin' module, but affect or return the
colors currently used for drawing instead of the global default
colors. When a drawing object is created, its colors are set to
the window's default colors, which are in turn initialized from
the global default colors when the window is created.
- Method on drawing: setfont ()
- Method on drawing: baseline ()
- Method on drawing: lineheight ()
- Method on drawing: textbreak ()
- Method on drawing: textwidth ()
These functions are similar to the corresponding functions
described above for the `stdwin' module, but affect or use the
current drawing font instead of the global default font. When a
drawing object is created, its font is set to the window's default
font, which is in turn initialized from the global default font
when the window is created.
- Method on drawing: bitmap (POINT, BITMAP, MASK)
Draw the BITMAP with its top left corner at POINT. If the
optional MASK argument is present, it should be either the same
object as BITMAP, to draw only those bits that are set in the
bitmap, in the foreground color, or `None', to draw all bits (ones
are drawn in the foreground color, zeros in the background color).
- Method on drawing: cliprect (RECT)
Set the "clipping region" to a rectangle. The clipping region
limits the effect of all drawing operations, until it is changed
again or until the drawing object is closed. When a drawing
object is created the clipping region is set to the entire window.
When an object to be drawn falls partly outside the clipping
region, the set of pixels drawn is the intersection of the clipping
region and the set of pixels that would be drawn by the same
operation in the absence of a clipping region. clipping region
- Method on drawing: noclip ()
Reset the clipping region to the entire window.
- Method on drawing: close ()
- Method on drawing: enddrawing ()
Discard the drawing object. It should not be used again.
File: python-lib.info, Node: Menu Object, Next: Bitmap Object, Prev: Drawing Object, Up: stdwin
Menu Object Methods
-------------------
A menu object represents a menu. The menu is destroyed when the menu
object is deleted. The following methods are defined:
- Method on menu: additem (TEXT, SHORTCUT)
Add a menu item with given text. The shortcut must be a string of
length 1, or omitted (to specify no shortcut).
- Method on menu: setitem (I, TEXT)
Set the text of item number I.
- Method on menu: enable (I, FLAG)
Enable or disables item I.
- Method on menu: check (I, FLAG)
Set or clear the "check mark" for item I.
- Method on menu: close ()
Discard the menu object. It should not be used again.
File: python-lib.info, Node: Bitmap Object, Next: Text-edit Object, Prev: Menu Object, Up: stdwin
Bitmap Object Methods
---------------------
A bitmap represents a rectangular array of bits. The top left bit has
coordinate (0, 0). A bitmap can be drawn with the `bitmap' method of a
drawing object. The following methods are defined:
- Method on bitmap: getsize ()
Return a tuple representing the width and height of the bitmap.
(This returns the values that have been passed to the `newbitmap'
function.)
- Method on bitmap: setbit (POINT, BIT)
Set the value of the bit indicated by POINT to BIT.
- Method on bitmap: getbit (POINT)
Return the value of the bit indicated by POINT.
- Method on bitmap: close ()
Discard the bitmap object. It should not be used again.
File: python-lib.info, Node: Text-edit Object, Next: Stdwin Example, Prev: Bitmap Object, Up: stdwin
Text-edit Object Methods
------------------------
A text-edit object represents a text-edit block. For semantics, see
the STDWIN documentation for C programmers. The following methods
exist:
- Method on text-edit: arrow (CODE)
Pass an arrow event to the text-edit block. The CODE must be one
of `WC_LEFT', `WC_RIGHT', `WC_UP' or `WC_DOWN' (see module
`stdwinevents').
- Method on text-edit: draw (RECT)
Pass a draw event to the text-edit block. The rectangle specifies
the redraw area.
- Method on text-edit: event (TYPE, WINDOW, DETAIL)
Pass an event gotten from `stdwin.getevent()' to the text-edit
block. Return true if the event was handled.
- Method on text-edit: getfocus ()
Return 2 integers representing the start and end positions of the
focus, usable as slice indices on the string returned by
`gettext()'.
- Method on text-edit: getfocustext ()
Return the text in the focus.
- Method on text-edit: getrect ()
Return a rectangle giving the actual position of the text-edit
block. (The bottom coordinate may differ from the initial
position because the block automatically shrinks or grows to fit.)
- Method on text-edit: gettext ()
Return the entire text buffer.
- Method on text-edit: move (RECT)
Specify a new position for the text-edit block in the document.
- Method on text-edit: replace (STR)
Replace the text in the focus by the given string. The new focus
is an insert point at the end of the string.
- Method on text-edit: setfocus (I, J)
Specify the new focus. Out-of-bounds values are silently clipped.
- Method on text-edit: settext (STR)
Replace the entire text buffer by the given string and set the
focus to `(0, 0)'.
- Method on text-edit: setview (RECT)
Set the view rectangle to RECT. If RECT is `None', viewing mode
is reset. In viewing mode, all output from the text-edit object
is clipped to the viewing rectangle. This may be useful to
implement your own scrolling text subwindow.
- Method on text-edit: close ()
Discard the text-edit object. It should not be used again.
File: python-lib.info, Node: Stdwin Example, Prev: Text-edit Object, Up: stdwin
Example
-------
Here is a minimal example of using STDWIN in Python. It creates a
window and draws the string "Hello world" in the top left corner of the
window. The window will be correctly redrawn when covered and
re-exposed. The program quits when the close icon or menu item is
requested.
import stdwin
from stdwinevents import *
def main():
mywin = stdwin.open('Hello')
#
while 1:
(type, win, detail) = stdwin.getevent()
if type == WE_DRAW:
draw = win.begindrawing()
draw.text((0, 0), 'Hello, world')
del draw
elif type == WE_CLOSE:
break
main()
File: python-lib.info, Node: stdwinevents, Next: rect, Prev: stdwin, Up: STDWIN ONLY
Standard Module `stdwinevents'
==============================
This module defines constants used by STDWIN for event types
(`WE_ACTIVATE' etc.), command codes (`WC_LEFT' etc.) and selection
types (`WS_PRIMARY' etc.). Read the file for details. Suggested usage
is
>>> from stdwinevents import *
>>>
File: python-lib.info, Node: rect, Prev: stdwinevents, Up: STDWIN ONLY
Standard Module `rect'
======================
This module contains useful operations on rectangles. A rectangle is
defined as in module `stdwin': a pair of points, where a point is a
pair of integers. For example, the rectangle
(10, 20), (90, 80)
is a rectangle whose left, top, right and bottom edges are 10, 20, 90
and 80, respectively. Note that the positive vertical axis points down
(as in `stdwin').
The module defines the following objects:
- exception of module rect: error
The exception raised by functions in this module when they detect
an error. The exception argument is a string describing the
problem in more detail.
- data of module rect: empty
The rectangle returned when some operations return an empty result.
This makes it possible to quickly check whether a result is empty:
>>> import rect
>>> r1 = (10, 20), (90, 80)
>>> r2 = (0, 0), (10, 20)
>>> r3 = rect.intersect([r1, r2])
>>> if r3 is rect.empty: print 'Empty intersection'
Empty intersection
>>>
- function of module rect: is_empty (R)
Returns true if the given rectangle is empty. A rectangle `(LEFT,
TOP), (RIGHT, BOTTOM)' is empty if `LEFT >= RIGHT' or `TOP =>
BOTTOM'.
- function of module rect: intersect (LIST)
Returns the intersection of all rectangles in the list argument.
It may also be called with a tuple argument. Raises `rect.error'
if the list is empty. Returns `rect.empty' if the intersection of
the rectangles is empty.
- function of module rect: union (LIST)
Returns the smallest rectangle that contains all non-empty
rectangles in the list argument. It may also be called with a
tuple argument or with two or more rectangles as arguments.
Returns `rect.empty' if the list is empty or all its rectangles
are empty.
- function of module rect: pointinrect (POINT, RECT)
Returns true if the point is inside the rectangle. By definition,
a point `(H, V)' is inside a rectangle `(LEFT, TOP), (RIGHT,
BOTTOM)' if `LEFT <= H < RIGHT' and `TOP <= V < BOTTOM'.
- function of module rect: inset (RECT, (DH, DV))
Returns a rectangle that lies inside the `rect' argument by DH
pixels horizontally and DV pixels vertically. If DH or DV is
negative, the result lies outside RECT.
- function of module rect: rect2geom (RECT)
Converts a rectangle to geometry representation: `(LEFT, TOP),
(WIDTH, HEIGHT)'.
- function of module rect: geom2rect (GEOM)
Converts a rectangle given in geometry representation back to the
standard rectangle representation `(LEFT, TOP), (RIGHT, BOTTOM)'.
File: python-lib.info, Node: SGI IRIX ONLY, Next: SUNOS ONLY, Prev: STDWIN ONLY, Up: Top
SGI IRIX ONLY
*************
The modules described in this chapter provide interfaces to features
that are unique to SGI's IRIX operating system (versions 4 and 5).
* Menu:
* al::
* AL (uppercase)::
* fl::
* FL (uppercase)::
* flp::
* fm::
* gl::
* Standard Modules GL and DEVICE::
* imgfile::
File: python-lib.info, Node: al, Next: AL (uppercase), Prev: SGI IRIX ONLY, Up: SGI IRIX ONLY
Built-in Module `al'
====================
This module provides access to the audio facilities of the Indigo and
4D/35 workstations, described in section 3A of the IRIX 4.0 man pages
(and also available as an option in IRIX 3.3). You'll need to read
those man pages to understand what these functions do! Some of the
functions are not available in releases below 4.0.5. Again, see the
manual to check whether a specific function is available on your
platform.
Symbolic constants from the C header file `<audio.h>' are defined in
the standard module `AL', see below.
*Warning:* the current version of the audio library may dump core when
bad argument values are passed rather than returning an error status.
Unfortunately, since the precise circumstances under which this may
happen are undocumented and hard to check, the Python interface can
provide no protection against this kind of problems. (One example is
specifying an excessive queue size -- there is no documented upper
limit.)
Module `al' defines the following functions:
- function of module al: openport (NAME, DIRECTION, CONFIG)
Equivalent to the C function ALopenport(). The name and direction
arguments are strings. The optional config argument is an opaque
configuration object as returned by `al.newconfig()'. The return
value is an opaque port object; methods of port objects are
described below.
- function of module al: newconfig ()
Equivalent to the C function ALnewconfig(). The return value is a
new opaque configuration object; methods of configuration objects
are described below.
- function of module al: queryparams (DEVICE)
Equivalent to the C function ALqueryparams(). The device argument
is an integer. The return value is a list of integers containing
the data returned by ALqueryparams().
- function of module al: getparams (DEVICE, LIST)
Equivalent to the C function ALgetparams(). The device argument
is an integer. The list argument is a list such as returned by
`queryparams'; it is modified in place (!).
- function of module al: setparams (DEVICE, LIST)
Equivalent to the C function ALsetparams(). The device argument
is an integer.The list argument is a list such as returned by
`al.queryparams'.
Configuration objects (returned by `al.newconfig()' have the following
methods:
- Method on audio configuration object: getqueuesize ()
Return the queue size; equivalent to the C function
ALgetqueuesize().
- Method on audio configuration object: setqueuesize (SIZE)
Set the queue size; equivalent to the C function ALsetqueuesize().
- Method on audio configuration object: getwidth ()
Get the sample width; equivalent to the C function ALgetwidth().
- Method on audio configuration object: getwidth (WIDTH)
Set the sample width; equivalent to the C function ALsetwidth().
- Method on audio configuration object: getchannels ()
Get the channel count; equivalent to the C function
ALgetchannels().
- Method on audio configuration object: setchannels (NCHANNELS)
Set the channel count; equivalent to the C function
ALsetchannels().
- Method on audio configuration object: getsampfmt ()
Get the sample format; equivalent to the C function ALgetsampfmt().
- Method on audio configuration object: setsampfmt (SAMPFMT)
Set the sample format; equivalent to the C function ALsetsampfmt().
- Method on audio configuration object: getfloatmax ()
Get the maximum value for floating sample formats; equivalent to
the C function ALgetfloatmax().
- Method on audio configuration object: setfloatmax (FLOATMAX)
Set the maximum value for floating sample formats; equivalent to
the C function ALsetfloatmax().
Port objects (returned by `al.openport()' have the following methods:
- Method on audio port object: closeport ()
Close the port; equivalent to the C function ALcloseport().
- Method on audio port object: getfd ()
Return the file descriptor as an int; equivalent to the C function
ALgetfd().
- Method on audio port object: getfilled ()
Return the number of filled samples; equivalent to the C function
ALgetfilled().
- Method on audio port object: getfillable ()
Return the number of fillable samples; equivalent to the C function
ALgetfillable().
- Method on audio port object: readsamps (NSAMPLES)
Read a number of samples from the queue, blocking if necessary;
equivalent to the C function ALreadsamples. The data is returned
as a string containing the raw data (e.g. 2 bytes per sample in
big-endian byte order (high byte, low byte) if you have set the
sample width to 2 bytes.
- Method on audio port object: writesamps (SAMPLES)
Write samples into the queue, blocking if necessary; equivalent to
the C function ALwritesamples. The samples are encoded as
described for the `readsamps' return value.
- Method on audio port object: getfillpoint ()
Return the `fill point'; equivalent to the C function
ALgetfillpoint().
- Method on audio port object: setfillpoint (FILLPOINT)
Set the `fill point'; equivalent to the C function
ALsetfillpoint().
- Method on audio port object: getconfig ()
Return a configuration object containing the current configuration
of the port; equivalent to the C function ALgetconfig().
- Method on audio port object: setconfig (CONFIG)
Set the configuration from the argument, a configuration object;
equivalent to the C function ALsetconfig().
- Method on audio port object: getstatus (LIST)
Get status information on last error equivalent to C function
ALgetstatus().
File: python-lib.info, Node: AL (uppercase), Next: fl, Prev: al, Up: SGI IRIX ONLY
Standard Module `AL'
====================
This module defines symbolic constants needed to use the built-in
module `al' (see above); they are equivalent to those defined in the C
header file `<audio.h>' except that the name prefix `AL_' is omitted.
Read the module source for a complete list of the defined names.
Suggested use:
import al
from AL import *
File: python-lib.info, Node: fl, Next: FL (uppercase), Prev: AL (uppercase), Up: SGI IRIX ONLY
Built-in Module `fl'
====================
This module provides an interface to the FORMS Library by Mark
Overmars, version 2.0b. For more info about FORMS, write to
markov@cs.ruu.nl.
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
button 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 avaiable, 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()'.
* Menu:
* Functions defined in module fl::
* Form object::
* FORMS object::
File: python-lib.info, Node: Functions defined in module fl, Next: Form object, Prev: fl, Up: fl
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:
- function of module 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.
- function of module fl: do_forms ()
The standard FORMS main loop. Returns a Python object representing
the FORMS object needing interaction, or the special value
`FL.EVENT'.
- function of module fl: check_forms ()
Check for FORMS events. Returns what `do_forms' above returns, or
`None' if there is no event that immediately needs interaction.
- function of module fl: set_event_call_back (FUNCTION)
Set the event callback function.
- function of module fl: set_graphics_mode (RGBMODE, DOUBLEBUFFERING)
Set the graphics modes.
- function of module fl: get_rgbmode ()
Return the current rgb mode. This is the value of the C global
variable `fl_rgbmode'.
- function of module fl: show_message (STR1, STR2, STR3)
Show a dialog box with a three-line message and an OK button.
- function of module 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.
- function of module 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' or `3'). The BUT2 and BUT3 arguments are optional.
- function of module 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.
- function of module fl: show_file_selector (MESSAGE, DIRECTORY,
PATTERN, DEFAULT)
Show a dialog box inm which the user can select a file. It returns
the absolute filename selected by the user, or `None' if the user
presses Cancel.
- function of module fl: get_directory ()
- function of module fl: get_pattern ()
- function of module 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.
- function of module fl: qdevice (DEV)
- function of module fl: unqdevice (DEV)
- function of module fl: isqueued (DEV)
- function of module fl: qtest ()
- function of module fl: qread ()
- function of module fl: qreset ()
- function of module fl: qenter (DEV, VAL)
- function of module fl: get_mouse ()
- function of module 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 value
`FL.EVENT' and you should call `fl.qread()' to read the event from
the queue. Don't use the equivalent GL functions!
- function of module fl: color ()
- function of module fl: mapcolor ()
- function of module fl: getmcolor ()
See the description in the FORMS documentation of `fl_color',
`fl_mapcolor' and `fl_getmcolor'.
File: python-lib.info, Node: Form object, Next: FORMS object, Prev: Functions defined in module fl, Up: fl
Form object methods and data attributes
---------------------------------------
Form objects (returned by `fl.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_...' functions 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.
- Method on form object: show_form (PLACEMENT, BORDERTYPE, NAME)
Show the form.
- Method on form object: hide_form ()
Hide the form.
- Method on form object: redraw_form ()
Redraw the form.
- Method on form object: set_form_position (X, Y)
Set the form's position.
- Method on form object: freeze_form ()
Freeze the form.
- Method on form object: unfreeze_form ()
Unfreeze the form.
- Method on form object: activate_form ()
Activate the form.
- Method on form object: deactivate_form ()
Deactivate the form.
- Method on form object: bgn_group ()
Begin a new group of objects; return a group object.
- Method on form object: end_group ()
End the current group of objects.
- Method on form object: find_first ()
Find the first object in the form.
- Method on form object: find_last ()
Find the last object in the form.
- Method on form object: add_box (TYPE, X, Y, W, H, NAME)
Add a box object to the form. No extra methods.
- Method on form object: add_text (TYPE, X, Y, W, H, NAME)
Add a text object to the form. No extra methods.
- Method on form object: add_clock (TYPE, X, Y, W, H, NAME)
Add a clock object to the form.
Method: `get_clock'.
- Method on form object: add_button (TYPE, X, Y, W, H, NAME)
Add a button object to the form.
Methods: `get_button', `set_button'.
- Method on form object: add_lightbutton (TYPE, X, Y, W, H, NAME)
Add a lightbutton object to the form.
Methods: `get_button', `set_button'.
- Method on form object: add_roundbutton (TYPE, X, Y, W, H, NAME)
Add a roundbutton object to the form.
Methods: `get_button', `set_button'.
- Method on form object: 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'.
- Method on form object: 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'.
- Method on form object: 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'.
- Method on form object: 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'.
- Method on form object: 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'.
- Method on form object: add_input (TYPE, X, Y, W, H, NAME)
Add a input object to the form.
Methods: `set_input', `get_input', `set_input_color',
`set_input_return'.
- Method on form object: add_menu (TYPE, X, Y, W, H, NAME)
Add a menu object to the form.
Methods: `set_menu', `get_menu', `addto_menu'.
- Method on form object: 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'.
- Method on form object: 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'.
- Method on form object: 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*
*Type* -- *Meaning*
`window'
int (read-only) -- GL window id
`w'
float -- form width
`h'
float -- form height
`x'
float -- form x origin
`y'
float -- form y origin
`deactivated'
int -- nonzero if form is deactivated
`visible'
int -- nonzero if form is visible
`frozen'
int -- nonzero if form is frozen
`doublebuf'
int -- nonzero if double buffering on
File: python-lib.info, Node: FORMS object, Prev: Form object, Up: fl
FORMS object methods and data attributes
----------------------------------------
Besides methods specific to particular kinds of FORMS objects, all
FORMS objects also have the following methods:
- Method on 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()' or
`fl.check_forms()' when they need interaction.) Call this method
without arguments to remove the callback function.
- Method on FORMS object: delete_object ()
Delete the object.
- Method on FORMS object: show_object ()
Show the object.
- Method on FORMS object: hide_object ()
Hide the object.
- Method on FORMS object: redraw_object ()
Redraw the object.
- Method on FORMS object: freeze_object ()
Freeze the object.
- Method on FORMS object: unfreeze_object ()
Unfreeze the object.
FORMS objects have these data attributes; see the FORMS documentation:
*Name*
*Type* -- *Meaning*
`objclass'
int (read-only) -- object class
`type'
int (read-only) -- object type
`boxtype'
int -- box type
`x'
float -- x origin
`y'
float -- y origin
`w'
float -- width
`h'
float -- height
`col1'
int -- primary color
`col2'
int -- secondary color
`align'
int -- alignment
`lcol'
int -- label color
`lsize'
float -- label font size
`label'
string -- label string
`lstyle'
int -- label style
`pushed'
int (read-only) -- (see FORMS docs)
`focus'
int (read-only) -- (see FORMS docs)
`belowmouse'
int (read-only) -- (see FORMS docs)
`frozen'
int (read-only) -- (see FORMS docs)
`active'
int (read-only) -- (see FORMS docs)
`input'
int (read-only) -- (see FORMS docs)
`visible'
int (read-only) -- (see FORMS docs)
`radio'
int (read-only) -- (see FORMS docs)
`automatic'
int (read-only) -- (see FORMS docs)
File: python-lib.info, Node: FL (uppercase), Next: flp, Prev: fl, Up: SGI IRIX ONLY
Standard Module `FL'
====================
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 *
File: python-lib.info, Node: flp, Next: fm, Prev: FL (uppercase), Up: SGI IRIX ONLY
Standard Module `flp'
=====================
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!
File: python-lib.info, Node: fm, Next: gl, Prev: flp, Up: SGI IRIX ONLY
Built-in Module `fm'
====================
This module provides access to the IRIS *Font Manager* library. It is
available only on Silicon Graphics machines. See also: 4Sight User's
Guide, Section 1, Chapter 5: Using the IRIS Font Manager.
This is not yet a full interface to the IRIS Font Manager. Among the
unsupported features are: matrix operations; cache operations;
character operations (use string operations instead); some details of
font info; individual glyph metrics; and printer matching.
It supports the following operations:
- function of module fm: init ()
Initialization function. Calls `fminit()'. It is normally not
necessary to call this function, since it is called automatically
the first time the `fm' module is imported.
- function of module fm: findfont (FONTNAME)
Return a font handle object. Calls `fmfindfont(FONTNAME)'.
- function of module fm: enumerate ()
Returns a list of available font names. This is an interface to
`fmenumerate()'.
- function of module fm: prstr (STRING)
Render a string using the current font (see the `setfont()' font
handle method below). Calls `fmprstr(STRING)'.
- function of module fm: setpath (STRING)
Sets the font search path. Calls `fmsetpath(string)'. (XXX Does
not work!?!)
- function of module fm: fontpath ()
Returns the current font search path.
Font handle objects support the following operations:
- Method on font handle: scalefont (FACTOR)
Returns a handle for a scaled version of this font. Calls
`fmscalefont(FH, FACTOR)'.
- Method on font handle: setfont ()
Makes this font the current font. Note: the effect is undone
silently when the font handle object is deleted. Calls
`fmsetfont(FH)'.
- Method on font handle: getfontname ()
Returns this font's name. Calls `fmgetfontname(FH)'.
- Method on font handle: getcomment ()
Returns the comment string associated with this font. Raises an
exception if there is none. Calls `fmgetcomment(FH)'.
- Method on font handle: getfontinfo ()
Returns a tuple giving some pertinent data about this font. This
is an interface to `fmgetfontinfo()'. The returned tuple contains
the following numbers: `(PRINTERMATCHED, FIXED_WIDTH, XORIG,
YORIG, XSIZE, YSIZE, HEIGHT, NGLYPHS)'.
- Method on font handle: getstrwidth (STRING)
Returns the width, in pixels, of the string when drawn in this
font. Calls `fmgetstrwidth(FH, STRING)'.