diff options
author | Guido van Rossum <guido@python.org> | 2007-05-14 22:51:27 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-14 22:51:27 (GMT) |
commit | 360e4b8fb19f34360093bc15ef9aad13115a6069 (patch) | |
tree | 482111f59aab9c266f8451b3c832890cbad9cb16 /Doc/lib | |
parent | a8add0ec5ef05c26e1641b8310b65ddd75c0fec3 (diff) | |
download | cpython-360e4b8fb19f34360093bc15ef9aad13115a6069.zip cpython-360e4b8fb19f34360093bc15ef9aad13115a6069.tar.gz cpython-360e4b8fb19f34360093bc15ef9aad13115a6069.tar.bz2 |
Merged revisions 55325-55327 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r55326 | guido.van.rossum | 2007-05-14 15:07:35 -0700 (Mon, 14 May 2007) | 2 lines
Don't use err.message, use err.args[0].
................
r55327 | guido.van.rossum | 2007-05-14 15:11:37 -0700 (Mon, 14 May 2007) | 259 lines
Merged revisions 54988-55226,55228-55323 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r54995 | neal.norwitz | 2007-04-26 23:45:32 -0700 (Thu, 26 Apr 2007) | 3 lines
This gets the test working on Solaris. It seems a little hokey to me,
but the test passed on Linux and Solaris, hopefully other platforms too.
........
r55002 | georg.brandl | 2007-04-27 12:20:00 -0700 (Fri, 27 Apr 2007) | 2 lines
Version fix (bug #1708710)
........
r55021 | neal.norwitz | 2007-04-29 16:53:24 -0700 (Sun, 29 Apr 2007) | 1 line
There really are some tests that are problematic.
........
r55024 | kristjan.jonsson | 2007-04-30 08:17:46 -0700 (Mon, 30 Apr 2007) | 1 line
Complete revamp of PCBuild8 directory. Use subdirectories for each project under the main pcbuild solution. Now make extensive use of property sheets to simplify project configuration. x64 build fully supported, and the process for building PGO version (Profiler Guided Optimization) simplified. All projects are now present, except _ssl, which needs to be reimplemented. Also, some of the projects that require external libraries need extra work to fully compile on x64.
........
r55025 | thomas.heller | 2007-04-30 08:44:17 -0700 (Mon, 30 Apr 2007) | 4 lines
Make sure to call PyErr_NoMemory() in several places where
PyMem_Malloc() could potentially fail.
Will backport to the release25-maint branch.
........
r55027 | thomas.heller | 2007-04-30 09:04:57 -0700 (Mon, 30 Apr 2007) | 8 lines
When accessing the .value attribute of a c_wchar_p instance, and the
instance does not point to a valid wchar_t zero-terminated string,
raise a ValueError. c_char_p does this already.
The ValueError message now contains the correct pointer address.
Will backport to release25-maint.
........
r55036 | georg.brandl | 2007-04-30 23:04:11 -0700 (Mon, 30 Apr 2007) | 2 lines
Bug #1710295: exceptions are now new-style classes.
........
r55038 | georg.brandl | 2007-04-30 23:08:15 -0700 (Mon, 30 Apr 2007) | 2 lines
Patch #1710352: add missing public functions to locale.__all__.
........
r55041 | vinay.sajip | 2007-05-01 03:20:03 -0700 (Tue, 01 May 2007) | 1 line
Added new optional credentials argument to SMTPHandler.__init__, and smtp.login() is now called in SMTPHandler.emit() if credentials are specified.
........
r55042 | vinay.sajip | 2007-05-01 03:21:45 -0700 (Tue, 01 May 2007) | 1 line
Added documentation for new optional credentials argument to SMTPHandler.__init__().
........
r55070 | neal.norwitz | 2007-05-01 21:47:55 -0700 (Tue, 01 May 2007) | 3 lines
Stop using PyMem_FREE while the GIL is not held. For details see:
http://mail.python.org/pipermail/python-dev/2007-May/072896.html
........
r55080 | armin.rigo | 2007-05-02 12:23:31 -0700 (Wed, 02 May 2007) | 6 lines
Fix for #1303614 and #1174712:
- __dict__ descriptor abuse for subclasses of built-in types
- subclassing from both ModuleType and another built-in types
Thanks zseil for the patch.
........
r55083 | georg.brandl | 2007-05-02 13:02:29 -0700 (Wed, 02 May 2007) | 3 lines
Actually raise an exception before calling ast_error_finish.
Triggers an assertion otherwise.
........
r55087 | neal.norwitz | 2007-05-02 23:47:18 -0700 (Wed, 02 May 2007) | 1 line
Handle a couple of uncaught errors. This should be backported
........
r55090 | neal.norwitz | 2007-05-03 00:20:57 -0700 (Thu, 03 May 2007) | 4 lines
Remove dead code. This code couldn't be reached because earlier in
the function there is another check for z != Py_None.
........
r55092 | thomas.heller | 2007-05-03 05:02:08 -0700 (Thu, 03 May 2007) | 1 line
Fix building _ctypes.pyd for x64 / Windows.
........
r55093 | thomas.heller | 2007-05-03 05:05:20 -0700 (Thu, 03 May 2007) | 1 line
Don't truncate pointers to integers (on win64 platform).
........
r55094 | walter.doerwald | 2007-05-03 08:13:55 -0700 (Thu, 03 May 2007) | 3 lines
Clarify the behaviour of PyUnicode_DecodeUTF16(): A BOM is only skipped
in native order mode, and only if it's the first two bytes.
........
r55101 | kristjan.jonsson | 2007-05-03 13:04:53 -0700 (Thu, 03 May 2007) | 2 lines
Fix pcbuild8 after recent overhaul: Added the version resource to python26.dll. Adjust stacksize to 2Mb and made large address aware for 32 bits, and set stacksize to 3Mb for 64 bits.
Todo: Set .dll optimized load addresses, and side-by-side packaging of the python26.dll.
........
r55102 | kristjan.jonsson | 2007-05-03 13:09:56 -0700 (Thu, 03 May 2007) | 1 line
Fix those parts in the testsuite that assumed that sys.maxint would cause overflow on x64. Now the testsuite is well behaved on that platform.
........
r55103 | kristjan.jonsson | 2007-05-03 13:27:03 -0700 (Thu, 03 May 2007) | 11 lines
Fix problems in x64 build that were discovered by the testsuite:
- Reenable modules on x64 that had been disabled aeons ago for Itanium.
- Cleared up confusion about compilers for 64 bit windows. There is only Itanium and x64. Added macros MS_WINI64 and MS_WINX64 for those rare cases where it matters, such as the disabling of modules above.
- Set target platform (_WIN32_WINNT and WINVER) to 0x0501 (XP) for x64, and 0x0400 (NT 4.0) otherwise, which are the targeted minimum platforms.
- Fixed thread_nt.h. The emulated InterlockedCompareExchange function didn?\194?\180t work on x64, probaby due to the lack of a "volatile" specifier. Anyway, win95 is no longer a target platform.
- Itertools module used wrong constant to check for overflow in count()
- PyInt_AsSsize_t couldn't deal with attribute error when accessing the __long__ member.
- PyLong_FromSsize_t() incorrectly specified that the operand were unsigned.
With these changes, the x64 passes the testsuite, for those modules present.
........
r55107 | kristjan.jonsson | 2007-05-03 17:25:08 -0700 (Thu, 03 May 2007) | 1 line
Revert compiler comment to AMD64 for x64/AMD64 builds.
........
r55115 | thomas.heller | 2007-05-04 00:14:39 -0700 (Fri, 04 May 2007) | 4 lines
Fix some ctypes test crashes, when running with a debug Python
version on win64 by using proper argtypes and restype function
attributes.
........
r55117 | thomas.heller | 2007-05-04 01:20:41 -0700 (Fri, 04 May 2007) | 4 lines
On 64-bit Windows, ffi_arg must be 8 bytes long. This fixes the
remaining crashes in the ctypes tests, when functions return float or
double types.
........
r55120 | kristjan.jonsson | 2007-05-04 08:48:15 -0700 (Fri, 04 May 2007) | 1 line
Update the pcbuild8 solution. Straightened out the _ctypes project by using a .vsproj file and a masm64.rules file to avoid redundancy
........
r55121 | kristjan.jonsson | 2007-05-04 10:28:06 -0700 (Fri, 04 May 2007) | 1 line
Minor fix of PCBuild8/_ctypes vcproj, moving include dir into the .vsprops file.
........
r55129 | thomas.heller | 2007-05-04 12:54:22 -0700 (Fri, 04 May 2007) | 3 lines
Do not truncate 64-bit pointers to 32-bit integers.
Fixes SF #1703286, will backport to release25-maint.
........
r55131 | thomas.heller | 2007-05-04 12:56:32 -0700 (Fri, 04 May 2007) | 1 line
Oops, these tests do not run on Windows CE.
........
r55140 | brett.cannon | 2007-05-04 18:34:02 -0700 (Fri, 04 May 2007) | 2 lines
Deprecate BaseException.message as per PEP 352.
........
r55154 | georg.brandl | 2007-05-05 11:55:37 -0700 (Sat, 05 May 2007) | 2 lines
Bug #1713535: typo in logging example.
........
r55158 | vinay.sajip | 2007-05-06 10:53:37 -0700 (Sun, 06 May 2007) | 1 line
Updates of recent changes to logging.
........
r55165 | neal.norwitz | 2007-05-07 00:02:26 -0700 (Mon, 07 May 2007) | 1 line
Verify changes to the trunk go to the normal checkins list
........
r55169 | kristjan.jonsson | 2007-05-07 09:46:54 -0700 (Mon, 07 May 2007) | 1 line
As per Armin Rigo's suggestion, remove special handing from intobject.c to deal with the peculiarities of classobject's implementation of the number protocol. The nb_long method of classobject now falls back to nb_int if there is no __long__ attribute present.
........
r55197 | collin.winter | 2007-05-08 21:14:36 -0700 (Tue, 08 May 2007) | 9 lines
Fix a bug in test.test_support.open_urlresource().
If the call to requires() doesn't precede the filesystem check, we get the following situation:
1. ./python Lib/test/regrtest.py test_foo # test needs urlfetch, not enabled, so skipped
2. ./python Lib/test/regrtest.py -u urlfetch test_foo # test runs
3. ./python Lib/test/regrtest.py test_foo # test runs (!)
By moving the call to requires() *before* the filesystem check, the fact that fetched files are cached on the local disk becomes an implementation detail, rather than a semantics-changing point of note.
........
r55198 | neal.norwitz | 2007-05-08 23:43:15 -0700 (Tue, 08 May 2007) | 1 line
Add markup for True/False. Will backport
........
r55205 | walter.doerwald | 2007-05-09 11:10:47 -0700 (Wed, 09 May 2007) | 4 lines
Backport checkin:
Fix a segfault when b"" was passed to b2a_qp() -- it was using strchr()
instead of memchr().
........
r55241 | neal.norwitz | 2007-05-10 22:55:15 -0700 (Thu, 10 May 2007) | 6 lines
Don't ever report a failure when the sum of the reference count differences
are zero. This should help reduce the false positives.
The message about references leaking is maintained to provide as much
info as possible rather than simply suppressing the message at the source.
........
r55242 | neal.norwitz | 2007-05-10 23:23:01 -0700 (Thu, 10 May 2007) | 1 line
Fix typo in docstring (the module is popen2, not 3).
........
r55244 | neal.norwitz | 2007-05-10 23:56:52 -0700 (Thu, 10 May 2007) | 1 line
Remove trailing whitespace in docstring
........
r55245 | neal.norwitz | 2007-05-10 23:57:33 -0700 (Thu, 10 May 2007) | 1 line
Deprecate os.popen* and popen2 module in favor of the subprocess module.
........
r55247 | neal.norwitz | 2007-05-11 00:13:30 -0700 (Fri, 11 May 2007) | 1 line
Deprecate os.popen* and popen2 module in favor of the subprocess module. (forgot the doc)
........
r55253 | georg.brandl | 2007-05-11 02:41:37 -0700 (Fri, 11 May 2007) | 3 lines
Remove an XXX that is unnecessary.
........
r55258 | georg.brandl | 2007-05-11 04:04:26 -0700 (Fri, 11 May 2007) | 2 lines
Patch #1714700: clarify os.linesep vs. tfiles opened in text mode.
(backport)
........
r55259 | georg.brandl | 2007-05-11 04:43:56 -0700 (Fri, 11 May 2007) | 2 lines
Update DDJ link.
........
r55273 | raymond.hettinger | 2007-05-11 10:59:59 -0700 (Fri, 11 May 2007) | 1 line
Better tests for posixpath.commonprefix
........
r55287 | georg.brandl | 2007-05-12 14:06:41 -0700 (Sat, 12 May 2007) | 2 lines
Bug #1046945: document SWIG options of distutils.
........
r55290 | georg.brandl | 2007-05-13 01:04:07 -0700 (Sun, 13 May 2007) | 2 lines
Add bz2 to content encodings.
........
r55297 | neal.norwitz | 2007-05-13 13:45:05 -0700 (Sun, 13 May 2007) | 3 lines
Remove Amoeba doc which was removed in version 1.0! according to Misc/HISTORY.
Hopefully Guido won't shed a tear. :-)
........
r55298 | neal.norwitz | 2007-05-13 13:54:19 -0700 (Sun, 13 May 2007) | 1 line
Remove references to stdwin which was removed long ago.
........
r55299 | neal.norwitz | 2007-05-13 14:13:42 -0700 (Sun, 13 May 2007) | 3 lines
Remove support for freebsd[23] which haven't been released since 2000
or earlier. http://www.freebsd.org/releases/index.html
........
r55320 | raymond.hettinger | 2007-05-14 13:52:31 -0700 (Mon, 14 May 2007) | 1 line
Small speedup.
........
................
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/lib.tex | 5 | ||||
-rw-r--r-- | Doc/lib/libamoeba.tex | 131 | ||||
-rw-r--r-- | Doc/lib/libdifflib.tex | 2 | ||||
-rw-r--r-- | Doc/lib/libexcs.tex | 22 | ||||
-rw-r--r-- | Doc/lib/liblogging.tex | 9 | ||||
-rw-r--r-- | Doc/lib/libos.tex | 30 | ||||
-rw-r--r-- | Doc/lib/libpopen2.tex | 1 | ||||
-rw-r--r-- | Doc/lib/libpprint.tex | 8 | ||||
-rw-r--r-- | Doc/lib/libstdwin.tex | 832 |
9 files changed, 36 insertions, 1004 deletions
diff --git a/Doc/lib/lib.tex b/Doc/lib/lib.tex index d87cd5e..05d84c3 100644 --- a/Doc/lib/lib.tex +++ b/Doc/lib/lib.tex @@ -423,11 +423,6 @@ and how to embed it in other applications. % OTHER PLATFORM-SPECIFIC STUFF % ============= -% XXX(nnorwitz): all these modules (down to next comment) need to be (re)moved. -%\input{libamoeba} % AMOEBA ONLY - -%\input{libstdwin} % STDWIN ONLY - \input{libsun} % SUNOS ONLY \input{libsunaudio} % XXX(nnorwitz): the modules below this comment should be kept. diff --git a/Doc/lib/libamoeba.tex b/Doc/lib/libamoeba.tex deleted file mode 100644 index ce6babc..0000000 --- a/Doc/lib/libamoeba.tex +++ /dev/null @@ -1,131 +0,0 @@ -\chapter{Amoeba Specific Services} - -\section{\module{amoeba} --- - Amoeba system support} - -\declaremodule{builtin}{amoeba} - \platform{Amoeba} -\modulesynopsis{Functions for the Amoeba operating system.} - - -This module provides some object types and operations useful for -Amoeba applications. It is only available on systems that support -Amoeba operations. RPC errors and other Amoeba errors are reported as -the exception \code{amoeba.error = 'amoeba.error'}. - -The module \module{amoeba} defines the following items: - -\begin{funcdesc}{name_append}{path, cap} -Stores a capability in the Amoeba directory tree. -Arguments are the pathname (a string) and the capability (a capability -object as returned by -\function{name_lookup()}). -\end{funcdesc} - -\begin{funcdesc}{name_delete}{path} -Deletes a capability from the Amoeba directory tree. -Argument is the pathname. -\end{funcdesc} - -\begin{funcdesc}{name_lookup}{path} -Looks up a capability. -Argument is the pathname. -Returns a -\dfn{capability} -object, to which various interesting operations apply, described below. -\end{funcdesc} - -\begin{funcdesc}{name_replace}{path, cap} -Replaces a capability in the Amoeba directory tree. -Arguments are the pathname and the new capability. -(This differs from -\function{name_append()} -in the behavior when the pathname already exists: -\function{name_append()} -finds this an error while -\function{name_replace()} -allows it, as its name suggests.) -\end{funcdesc} - -\begin{datadesc}{capv} -A table representing the capability environment at the time the -interpreter was started. -(Alas, modifying this table does not affect the capability environment -of the interpreter.) -For example, -\code{amoeba.capv['ROOT']} -is the capability of your root directory, similar to -\code{getcap("ROOT")} -in C. -\end{datadesc} - -\begin{excdesc}{error} -The exception raised when an Amoeba function returns an error. -The value accompanying this exception is a pair containing the numeric -error code and the corresponding string, as returned by the C function -\cfunction{err_why()}. -\end{excdesc} - -\begin{funcdesc}{timeout}{msecs} -Sets the transaction timeout, in milliseconds. -Returns the previous timeout. -Initially, the timeout is set to 2 seconds by the Python interpreter. -\end{funcdesc} - -\subsection{Capability Operations} - -Capabilities are written in a convenient \ASCII{} format, also used by the -Amoeba utilities -\emph{c2a}(U) -and -\emph{a2c}(U). -For example: - -\begin{verbatim} ->>> amoeba.name_lookup('/profile/cap') -aa:1c:95:52:6a:fa/14(ff)/8e:ba:5b:8:11:1a ->>> -\end{verbatim} -% -The following methods are defined for capability objects. - -\begin{methoddesc}[capability]{dir_list}{} -Returns a list of the names of the entries in an Amoeba directory. -\end{methoddesc} - -\begin{methoddesc}[capability]{b_read}{offset, maxsize} -Reads (at most) -\var{maxsize} -bytes from a bullet file at offset -\var{offset.} -The data is returned as a string. -EOF is reported as an empty string. -\end{methoddesc} - -\begin{methoddesc}[capability]{b_size}{} -Returns the size of a bullet file. -\end{methoddesc} - -\begin{methoddesc}[capability]{dir_append}{} -\funcline{dir_delete}{} -\funcline{dir_lookup}{} -\funcline{dir_replace}{} -Like the corresponding -\samp{name_}* -functions, but with a path relative to the capability. -(For paths beginning with a slash the capability is ignored, since this -is the defined semantics for Amoeba.) -\end{methoddesc} - -\begin{methoddesc}[capability]{std_info}{} -Returns the standard info string of the object. -\end{methoddesc} - -\begin{methoddesc}[capability]{tod_gettime}{} -Returns the time (in seconds since the Epoch, in UCT, as for \POSIX) from -a time server. -\end{methoddesc} - -\begin{methoddesc}[capability]{tod_settime}{t} -Sets the time kept by a time server. -\end{methoddesc} diff --git a/Doc/lib/libdifflib.tex b/Doc/lib/libdifflib.tex index acb5ed1..7fb8e92 100644 --- a/Doc/lib/libdifflib.tex +++ b/Doc/lib/libdifflib.tex @@ -302,7 +302,7 @@ emu \begin{seealso} - \seetitle[http://www.ddj.com/documents/s=1103/ddj8807c/] + \seetitle[http://www.ddj.com/184407970?pgno=5] {Pattern Matching: The Gestalt Approach}{Discussion of a similar algorithm by John W. Ratcliff and D. E. Metzener. This was published in diff --git a/Doc/lib/libexcs.tex b/Doc/lib/libexcs.tex index d119ed9..631c798 100644 --- a/Doc/lib/libexcs.tex +++ b/Doc/lib/libexcs.tex @@ -23,14 +23,10 @@ an ``associated value'' indicating the detailed cause of the error. This may be a string or a tuple containing several items of information (e.g., an error code and a string explaining the code). The associated value is the second argument to the -\keyword{raise}\stindex{raise} statement. For string exceptions, the -associated value itself will be stored in the variable named as the -second argument of the \keyword{except} clause (if any). For class -exceptions, that variable receives the exception instance. If the -exception class is derived from the standard root class -\exception{BaseException}, the associated value is present as the -exception instance's \member{args} attribute. If there is a single argument -(as is preferred), it is bound to the \member{message} attribute. +\keyword{raise}\stindex{raise} statement. If the exception class is +derived from the standard root class \exception{BaseException}, the +associated value is present as the exception instance's \member{args} +attribute. User code can raise built-in exceptions. This can be used to test an exception handler or to report an error condition ``just like'' the @@ -56,14 +52,8 @@ The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes (for that use \exception{Exception}). If \function{str()} or \function{unicode()} is called on an instance of this class, the representation of the argument(s) to the instance are returned or -the emptry string when there were no arguments. If only a single argument is -passed in, it is stored in the \member{message} attribute. If more than one -argument is passed in, \member{message} is set to the empty string. These -semantics are meant to reflect the fact that \member{message} is to store a -text message explaining why the exception had been raised. If more data needs -to be attached to the exception, attach it through arbitrary attributes on the -instance. All arguments are also stored in \member{args} as a tuple, but it will -eventually be deprecated and thus its use is discouraged. +the emptry string when there were no arguments. All arguments are +stored in \member{args} as a tuple. \versionadded{2.5} \end{excdesc} diff --git a/Doc/lib/liblogging.tex b/Doc/lib/liblogging.tex index dabab53..5783cbf 100644 --- a/Doc/lib/liblogging.tex +++ b/Doc/lib/liblogging.tex @@ -203,7 +203,7 @@ logged messages. For example: \begin{verbatim} FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s" logging.basicConfig(format=FORMAT) - dict = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' } + d = {'clientip': '192.168.0.1', 'user': 'fbloggs'} logging.warning("Protocol problem: %s", "connection reset", extra=d) \end{verbatim} @@ -1296,13 +1296,16 @@ The \class{SMTPHandler} class, located in the \module{logging.handlers} module, supports sending logging messages to an email address via SMTP. -\begin{classdesc}{SMTPHandler}{mailhost, fromaddr, toaddrs, subject} +\begin{classdesc}{SMTPHandler}{mailhost, fromaddr, toaddrs, subject\optional{, + credentials}} Returns a new instance of the \class{SMTPHandler} class. The instance is initialized with the from and to addresses and subject line of the email. The \var{toaddrs} should be a list of strings. To specify a non-standard SMTP port, use the (host, port) tuple format for the \var{mailhost} argument. If you use a string, the standard SMTP port -is used. +is used. If your SMTP server requires authentication, you can specify a +(username, password) tuple for the \var{credentials} argument. +\versionchanged[\var{credentials} was added]{2.6} \end{classdesc} \begin{methoddesc}{emit}{record} diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex index 638ed6b..2454e57 100644 --- a/Doc/lib/libos.tex +++ b/Doc/lib/libos.tex @@ -361,9 +361,8 @@ object, except that when the exit status is zero (termination without errors), \code{None} is returned. Availability: Macintosh, \UNIX, Windows. -The \module{subprocess} module provides more powerful facilities for -spawning new processes and retrieving their results; using that module -is preferable to using this function. +\deprecated{2.6}{This function is obsolete. Use the + \module{subprocess} module.} \versionchanged[This function worked unreliably under Windows in earlier versions of Python. This was due to the use of the @@ -380,10 +379,9 @@ Availability: Macintosh, \UNIX, Windows. \end{funcdesc} There are a number of different \function{popen*()} functions that -provide slightly different ways to create subprocesses. Note that the -\module{subprocess} module is easier to use and more powerful; -consider using that module before writing code using the -lower-level \function{popen*()} functions. +provide slightly different ways to create subprocesses. +\deprecated{2.6}{All of the \function{popen*()} functions are obsolete. + Use the \module{subprocess} module.} For each of the \function{popen*()} variants, if \var{bufsize} is specified, it specifies the buffer size for the I/O pipes. @@ -400,8 +398,7 @@ be passed to the shell (as with \function{os.system()}). These methods do not make it possible to retrieve the exit status from the child processes. The only way to control the input and output streams and also retrieve the return codes is to use the -\class{Popen3} and \class{Popen4} classes from the \refmodule{popen2} -module; these are only available on \UNIX. +\refmodule{subprocess} module; these are only available on \UNIX. For a discussion of possible deadlock conditions related to the use of these functions, see ``\ulink{Flow Control @@ -411,6 +408,8 @@ Issues}{popen2-flow-control.html}'' \begin{funcdesc}{popen2}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout})}. +\deprecated{2.6}{All of the \function{popen*()} functions are obsolete. + Use the \module{subprocess} module.} Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} @@ -418,6 +417,8 @@ Availability: Macintosh, \UNIX, Windows. \begin{funcdesc}{popen3}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout}, \var{child_stderr})}. +\deprecated{2.6}{All of the \function{popen*()} functions are obsolete. + Use the \module{subprocess} module.} Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} @@ -425,6 +426,8 @@ Availability: Macintosh, \UNIX, Windows. \begin{funcdesc}{popen4}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout_and_stderr})}. +\deprecated{2.6}{All of the \function{popen*()} functions are obsolete. + Use the \module{subprocess} module.} Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} @@ -2006,9 +2009,12 @@ Also available via \module{os.path}. \begin{datadesc}{linesep} The string used to separate (or, rather, terminate) lines on the -current platform. This may be a single character, such as \code{'\e -n'} for \POSIX{} or \code{'\e r'} for Mac OS, or multiple characters, -for example, \code{'\e r\e n'} for Windows. +current platform. This may be a single character, such as +\code{'\e n'} for \POSIX{} or \code{'\e r'} for Mac OS, or multiple +characters, for example, \code{'\e r\e n'} for Windows. +Do not use \var{os.linesep} as a line terminator when writing files +opened in text mode (the default); use a single \code{'\e n'} instead, +on all platforms. \end{datadesc} \begin{datadesc}{devnull} diff --git a/Doc/lib/libpopen2.tex b/Doc/lib/libpopen2.tex index 322a9b9..5d40e1a 100644 --- a/Doc/lib/libpopen2.tex +++ b/Doc/lib/libpopen2.tex @@ -5,6 +5,7 @@ \modulesynopsis{Subprocesses with accessible standard I/O streams.} \sectionauthor{Drew Csillag}{drew_csillag@geocities.com} +\deprecated{2.6}{This module is obsolete. Use the \module{subprocess} module.} This module allows you to spawn processes and connect to their input/output/error pipes and obtain their return codes under diff --git a/Doc/lib/libpprint.tex b/Doc/lib/libpprint.tex index 9203b3a..ce35b44 100644 --- a/Doc/lib/libpprint.tex +++ b/Doc/lib/libpprint.tex @@ -118,7 +118,7 @@ were added]{2.4} \begin{funcdesc}{isreadable}{object} Determine if the formatted representation of \var{object} is ``readable,'' or can be used to reconstruct the value using -\function{eval()}\bifuncindex{eval}. This always returns false for +\function{eval()}\bifuncindex{eval}. This always returns \code{False} for recursive objects. \begin{verbatim} @@ -176,10 +176,10 @@ objects don't need to be created. \begin{methoddesc}[PrettyPrinter]{isreadable}{object} Determine if the formatted representation of the object is ``readable,'' or can be used to reconstruct the value using -\function{eval()}\bifuncindex{eval}. Note that this returns false for +\function{eval()}\bifuncindex{eval}. Note that this returns \code{False} for recursive objects. If the \var{depth} parameter of the \class{PrettyPrinter} is set and the object is deeper than allowed, -this returns false. +this returns \code{False}. \end{methoddesc} \begin{methoddesc}[PrettyPrinter]{isrecursive}{object} @@ -199,7 +199,7 @@ object to be presented. The second is a dictionary which contains the context (direct and indirect containers for \var{object} that are affecting the presentation) as the keys; if an object needs to be presented which is already represented in \var{context}, the third -return value should be true. Recursive calls to the \method{format()} +return value should be \code{True}. Recursive calls to the \method{format()} method should add additional entries for containers to this dictionary. The third argument, \var{maxlevels}, gives the requested limit to recursion; this will be \code{0} if there is no requested diff --git a/Doc/lib/libstdwin.tex b/Doc/lib/libstdwin.tex deleted file mode 100644 index f2278e5..0000000 --- a/Doc/lib/libstdwin.tex +++ /dev/null @@ -1,832 +0,0 @@ -\chapter{Standard Windowing Interface} - -The modules in this chapter are available only on those systems where -the STDWIN library is available. STDWIN runs on \UNIX{} under X11 and -on the Macintosh. See CWI report CS-R8817. - -\warning{Using STDWIN is not recommended for new -applications. It has never been ported to Microsoft Windows or -Windows NT, and for X11 or the Macintosh it lacks important -functionality --- in particular, it has no tools for the construction -of dialogs. For most platforms, alternative, native solutions exist -(though none are currently documented in this manual): Tkinter for -\UNIX{} under X11, native Xt with Motif or Athena widgets for \UNIX{} -under X11, Win32 for Windows and Windows NT, and a collection of -native toolkit interfaces for the Macintosh.} - - -\section{\module{stdwin} --- - Platform-independent Graphical User Interface System} - -\declaremodule{builtin}{stdwin} -\modulesynopsis{Older graphical user interface system for X11 and Macintosh.} - - -This module defines several new object types and functions that -provide access to the functionality of STDWIN. - -On \UNIX{} running X11, it can only be used if the \envvar{DISPLAY} -environment variable is set or an explicit -\programopt{-display} \var{displayname} argument is passed to the -Python interpreter. - -Functions have names that usually resemble their C STDWIN counterparts -with the initial `w' dropped. Points are represented by pairs of -integers; rectangles by pairs of points. For a complete description -of STDWIN please refer to the documentation of STDWIN for C -programmers (aforementioned CWI report). - -\subsection{Functions Defined in Module \module{stdwin}} -\nodename{STDWIN Functions} - -The following functions are defined in the \module{stdwin} module: - -\begin{funcdesc}{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.\footnote{ - The Python version of STDWIN does not support draw procedures; - all drawing requests are reported as draw events.} -\end{funcdesc} - -\begin{funcdesc}{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 -\code{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 \refmodule{stdwinevents}. -\end{funcdesc} - -\begin{funcdesc}{pollevent}{} -Return the next event, if one is immediately available. -If no event is available, return \code{()}. -\end{funcdesc} - -\begin{funcdesc}{getactive}{} -Return the window that is currently active, or \code{None} if no -window is currently active. (This can be emulated by monitoring -WE_ACTIVATE and WE_DEACTIVATE events.) -\end{funcdesc} - -\begin{funcdesc}{listfontnames}{pattern} -Return the list of font names in the system that match the pattern (a -string). The pattern should normally be \code{'*'}; 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 \code{'*'} -matches any sequence of characters (including none) and \code{'?'} -matches any single character. -On the Macintosh this function currently returns an empty list. -\end{funcdesc} - -\begin{funcdesc}{setdefscrollbars}{hflag, vflag} -Set the flags controlling whether subsequently opened windows will -have horizontal and/or vertical scroll bars. -\end{funcdesc} - -\begin{funcdesc}{setdefwinpos}{h, v} -Set the default window position for windows opened subsequently. -\end{funcdesc} - -\begin{funcdesc}{setdefwinsize}{width, height} -Set the default window size for windows opened subsequently. -\end{funcdesc} - -\begin{funcdesc}{getdefscrollbars}{} -Return the flags controlling whether subsequently opened windows will -have horizontal and/or vertical scroll bars. -\end{funcdesc} - -\begin{funcdesc}{getdefwinpos}{} -Return the default window position for windows opened subsequently. -\end{funcdesc} - -\begin{funcdesc}{getdefwinsize}{} -Return the default window size for windows opened subsequently. -\end{funcdesc} - -\begin{funcdesc}{getscrsize}{} -Return the screen size in pixels. -\end{funcdesc} - -\begin{funcdesc}{getscrmm}{} -Return the screen size in millimetres. -\end{funcdesc} - -\begin{funcdesc}{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 whether you are on a machine that -supports more than two colors: -\begin{verbatim} -if stdwin.fetchcolor('black') != \ - stdwin.fetchcolor('red') != \ - stdwin.fetchcolor('white'): - print 'color machine' -else: - print 'monochrome machine' -\end{verbatim} -\end{funcdesc} - -\begin{funcdesc}{setfgcolor}{pixel} -Set the default foreground color. -This will become the default foreground color of windows opened -subsequently, including dialogs. -\end{funcdesc} - -\begin{funcdesc}{setbgcolor}{pixel} -Set the default background color. -This will become the default background color of windows opened -subsequently, including dialogs. -\end{funcdesc} - -\begin{funcdesc}{getfgcolor}{} -Return the pixel value of the current default foreground color. -\end{funcdesc} - -\begin{funcdesc}{getbgcolor}{} -Return the pixel value of the current default background color. -\end{funcdesc} - -\begin{funcdesc}{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 \function{textwidth()}, -\function{textbreak()}, \function{lineheight()} and -\function{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: -\code{'b'} = bold, -\code{'i'} = italic, -\code{'o'} = bold + italic, -\code{'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.) -\end{funcdesc} - -\begin{funcdesc}{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 -\method{menucreate()} below. -\warning{The menu only appears in a window as long as the object -returned by this call exists.} -\end{funcdesc} - -\begin{funcdesc}{newbitmap}{width, height} -Create a new bitmap object of the given dimensions. -Methods of bitmap objects are described below. -Not available on the Macintosh. -\end{funcdesc} - -\begin{funcdesc}{fleep}{} -Cause a beep or bell (or perhaps a `visual bell' or flash, hence the -name). -\end{funcdesc} - -\begin{funcdesc}{message}{string} -Display a dialog box containing the string. -The user must click OK before the function returns. -\end{funcdesc} - -\begin{funcdesc}{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, \exception{KeyboardInterrupt} is raised. -\end{funcdesc} - -\begin{funcdesc}{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, \exception{KeyboardInterrupt} is -raised. -\end{funcdesc} - -\begin{funcdesc}{askfile}{prompt, default, new} -Ask the user to specify a filename. If \var{new} is zero it must be -an existing file; otherwise, it must be a new file. If the user -cancels the dialog, \exception{KeyboardInterrupt} is raised. -\end{funcdesc} - -\begin{funcdesc}{setcutbuffer}{i, string} -Store the string in the system's cut buffer number \var{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. -\end{funcdesc} - -\begin{funcdesc}{getcutbuffer}{i} -Return the contents of the system's cut buffer number \var{i}. -\end{funcdesc} - -\begin{funcdesc}{rotatecutbuffers}{n} -On X11, rotate the 8 cut buffers by \var{n}. Ignored on the -Macintosh. -\end{funcdesc} - -\begin{funcdesc}{getselection}{i} -Return X11 selection number \var{i.} Selections are not cut buffers. -Selection numbers are defined in module \refmodule{stdwinevents}. -Selection \constant{WS_PRIMARY} is the \dfn{primary} selection (used -by \program{xterm}, for instance); selection \constant{WS_SECONDARY} -is the \dfn{secondary} selection; selection \constant{WS_CLIPBOARD} is -the \dfn{clipboard} selection (used by \program{xclipboard}). On the -Macintosh, this always returns an empty string. -\end{funcdesc} - -\begin{funcdesc}{resetselection}{i} -Reset selection number \var{i}, if this process owns it. (See window -method \method{setselection()}). -\end{funcdesc} - -\begin{funcdesc}{baseline}{} -Return the baseline of the current font (defined by STDWIN as the -vertical distance between the baseline and the top of the -characters). -\end{funcdesc} - -\begin{funcdesc}{lineheight}{} -Return the total line height of the current font. -\end{funcdesc} - -\begin{funcdesc}{textbreak}{str, width} -Return the number of characters of the string that fit into a space of -\var{width} -bits wide when drawn in the current font. -\end{funcdesc} - -\begin{funcdesc}{textwidth}{str} -Return the width in bits of the string when drawn in the current font. -\end{funcdesc} - -\begin{funcdesc}{connectionnumber}{} -\funcline{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; -\method{connectionnumber()} is named after the corresponding function in -X11 and STDWIN, while \method{fileno()} makes it possible to use the -\module{stdwin} module as a ``file'' object parameter to -\function{select.select()}. Note that if \constant{select()} implies that -input is possible on \module{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 -\function{stdwin.pollevent()} until it returns \code{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 \function{stdwin.pollevent()} -returns an event while \function{select()} does not find \module{stdwin} to -be ready, so you should read any pending events with -\function{stdwin.pollevent()} until it returns \code{None} before entering -a blocking \function{select()} call. -\withsubitem{(in module select)}{\ttindex{select()}} -\end{funcdesc} - -\subsection{Window Objects} -\nodename{STDWIN Window Objects} - -Window objects are created by \function{stdwin.open()}. They are closed -by their \method{close()} method or when they are garbage-collected. -Window objects have the following methods: - -\begin{methoddesc}[window]{begindrawing}{} -Return a drawing object, whose methods (described below) allow drawing -in the window. -\end{methoddesc} - -\begin{methoddesc}[window]{change}{rect} -Invalidate the given rectangle; this may cause a draw event. -\end{methoddesc} - -\begin{methoddesc}[window]{gettitle}{} -Returns the window's title string. -\end{methoddesc} - -\begin{methoddesc}[window]{getdocsize}{} -\begin{sloppypar} -Return a pair of integers giving the size of the document as set by -\method{setdocsize()}. -\end{sloppypar} -\end{methoddesc} - -\begin{methoddesc}[window]{getorigin}{} -Return a pair of integers giving the origin of the window with respect -to the document. -\end{methoddesc} - -\begin{methoddesc}[window]{gettitle}{} -Return the window's title string. -\end{methoddesc} - -\begin{methoddesc}[window]{getwinsize}{} -Return a pair of integers giving the size of the window. -\end{methoddesc} - -\begin{methoddesc}[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). -\end{methoddesc} - -\begin{methoddesc}[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.} -\end{methoddesc} - -\begin{methoddesc}[window]{scroll}{rect, point} -Scroll the given rectangle by the vector given by the point. -\end{methoddesc} - -\begin{methoddesc}[window]{setdocsize}{point} -Set the size of the drawing document. -\end{methoddesc} - -\begin{methoddesc}[window]{setorigin}{point} -Move the origin of the window (its upper left corner) -to the given point in the document. -\end{methoddesc} - -\begin{methoddesc}[window]{setselection}{i, str} -Attempt to set X11 selection number \var{i} to the string \var{str}. -(See \module{stdwin} function \function{getselection()} for the -meaning of \var{i}.) Return true if it succeeds. -If succeeds, the window ``owns'' the selection until -(a) another application takes ownership of the selection; or -(b) the window is deleted; or -(c) the application clears ownership by calling -\function{stdwin.resetselection(\var{i})}. When another application -takes ownership of the selection, a \constant{WE_LOST_SEL} event is -received for no particular window and with the selection number as -detail. Ignored on the Macintosh. -\end{methoddesc} - -\begin{methoddesc}[window]{settimer}{dsecs} -Schedule a timer event for the window in \code{\var{dsecs}/10} -seconds. -\end{methoddesc} - -\begin{methoddesc}[window]{settitle}{title} -Set the window's title string. -\end{methoddesc} - -\begin{methoddesc}[window]{setwincursor}{name} -\begin{sloppypar} -Set the window cursor to a cursor of the given name. It raises -\exception{RuntimeError} if no cursor of the given name exists. -Suitable names include -\code{'ibeam'}, -\code{'arrow'}, -\code{'cross'}, -\code{'watch'} -and -\code{'plus'}. -On X11, there are many more (see \code{<X11/cursorfont.h>}). -\end{sloppypar} -\end{methoddesc} - -\begin{methoddesc}[window]{setwinpos}{h, v} -Set the position of the window's upper left corner (relative to -the upper left corner of the screen). -\end{methoddesc} - -\begin{methoddesc}[window]{setwinsize}{width, height} -Set the window's size. -\end{methoddesc} - -\begin{methoddesc}[window]{show}{rect} -Try to ensure that the given rectangle of the document is visible in -the window. -\end{methoddesc} - -\begin{methoddesc}[window]{textcreate}{rect} -Create a text-edit object in the document at the given rectangle. -Methods of text-edit objects are described below. -\end{methoddesc} - -\begin{methoddesc}[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). -\end{methoddesc} - -\begin{methoddesc}[window]{close}{} -Discard the window object. It should not be used again. -\end{methoddesc} - -\subsection{Drawing Objects} - -Drawing objects are created exclusively by the window method -\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 \function{stdwin.getevent()} is called. -Drawing objects have the following methods: - -\begin{methoddesc}[drawing]{box}{rect} -Draw a box just inside a rectangle. -\end{methoddesc} - -\begin{methoddesc}[drawing]{circle}{center, radius} -Draw a circle with given center point and radius. -\end{methoddesc} - -\begin{methoddesc}[drawing]{elarc}{center, (rh, rv), (a1, a2)} -Draw an elliptical arc with given center point. -\code{(\var{rh}, \var{rv})} -gives the half sizes of the horizontal and vertical radii. -\code{(\var{a1}, \var{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. -\end{methoddesc} - -\begin{methoddesc}[drawing]{erase}{rect} -Erase a rectangle. -\end{methoddesc} - -\begin{methoddesc}[drawing]{fillcircle}{center, radius} -Draw a filled circle with given center point and radius. -\end{methoddesc} - -\begin{methoddesc}[drawing]{fillelarc}{center, (rh, rv), (a1, a2)} -Draw a filled elliptical arc; arguments as for \method{elarc()}. -\end{methoddesc} - -\begin{methoddesc}[drawing]{fillpoly}{points} -Draw a filled polygon given by a list (or tuple) of points. -\end{methoddesc} - -\begin{methoddesc}[drawing]{invert}{rect} -Invert a rectangle. -\end{methoddesc} - -\begin{methoddesc}[drawing]{line}{p1, p2} -Draw a line from point -\var{p1} -to -\var{p2}. -\end{methoddesc} - -\begin{methoddesc}[drawing]{paint}{rect} -Fill a rectangle. -\end{methoddesc} - -\begin{methoddesc}[drawing]{poly}{points} -Draw the lines connecting the given list (or tuple) of points. -\end{methoddesc} - -\begin{methoddesc}[drawing]{shade}{rect, percent} -Fill a rectangle with a shading pattern that is about -\var{percent} -percent filled. -\end{methoddesc} - -\begin{methoddesc}[drawing]{text}{p, str} -Draw a string starting at point p (the point specifies the -top left coordinate of the string). -\end{methoddesc} - -\begin{methoddesc}[drawing]{xorcircle}{center, radius} -\funcline{xorelarc}{center, (rh, rv), (a1, a2)} -\funcline{xorline}{p1, p2} -\funcline{xorpoly}{points} -Draw a circle, an elliptical arc, a line or a polygon, respectively, -in XOR mode. -\end{methoddesc} - -\begin{methoddesc}[drawing]{setfgcolor}{} -\funcline{setbgcolor}{} -\funcline{getfgcolor}{} -\funcline{getbgcolor}{} -These functions are similar to the corresponding functions described -above for the \module{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. -\end{methoddesc} - -\begin{methoddesc}[drawing]{setfont}{} -\funcline{baseline}{} -\funcline{lineheight}{} -\funcline{textbreak}{} -\funcline{textwidth}{} -These functions are similar to the corresponding functions described -above for the \module{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. -\end{methoddesc} - -\begin{methoddesc}[drawing]{bitmap}{point, bitmap, mask} -Draw the \var{bitmap} with its top left corner at \var{point}. -If the optional \var{mask} argument is present, it should be either -the same object as \var{bitmap}, to draw only those bits that are set -in the bitmap, in the foreground color, or \code{None}, to draw all -bits (ones are drawn in the foreground color, zeros in the background -color). -Not available on the Macintosh. -\end{methoddesc} - -\begin{methoddesc}[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. -\end{methoddesc} - -\begin{methoddesc}[drawing]{noclip}{} -Reset the clipping region to the entire window. -\end{methoddesc} - -\begin{methoddesc}[drawing]{close}{} -\funcline{enddrawing}{} -Discard the drawing object. It should not be used again. -\end{methoddesc} - -\subsection{Menu Objects} - -A menu object represents a menu. -The menu is destroyed when the menu object is deleted. -The following methods are defined: - - -\begin{methoddesc}[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). -\end{methoddesc} - -\begin{methoddesc}[menu]{setitem}{i, text} -Set the text of item number \var{i}. -\end{methoddesc} - -\begin{methoddesc}[menu]{enable}{i, flag} -Enable or disables item \var{i}. -\end{methoddesc} - -\begin{methoddesc}[menu]{check}{i, flag} -Set or clear the \dfn{check mark} for item \var{i}. -\end{methoddesc} - -\begin{methoddesc}[menu]{close}{} -Discard the menu object. It should not be used again. -\end{methoddesc} - -\subsection{Bitmap Objects} - -A bitmap represents a rectangular array of bits. -The top left bit has coordinate (0, 0). -A bitmap can be drawn with the \method{bitmap()} method of a drawing object. -Bitmaps are currently not available on the Macintosh. - -The following methods are defined: - - -\begin{methoddesc}[bitmap]{getsize}{} -Return a tuple representing the width and height of the bitmap. -(This returns the values that have been passed to the -\function{newbitmap()} function.) -\end{methoddesc} - -\begin{methoddesc}[bitmap]{setbit}{point, bit} -Set the value of the bit indicated by \var{point} to \var{bit}. -\end{methoddesc} - -\begin{methoddesc}[bitmap]{getbit}{point} -Return the value of the bit indicated by \var{point}. -\end{methoddesc} - -\begin{methoddesc}[bitmap]{close}{} -Discard the bitmap object. It should not be used again. -\end{methoddesc} - -\subsection{Text-edit Objects} - -A text-edit object represents a text-edit block. -For semantics, see the STDWIN documentation for \C{} programmers. -The following methods exist: - - -\begin{methoddesc}[text-edit]{arrow}{code} -Pass an arrow event to the text-edit block. -The \var{code} must be one of \constant{WC_LEFT}, \constant{WC_RIGHT}, -\constant{WC_UP} or \constant{WC_DOWN} (see module -\refmodule{stdwinevents}). -\end{methoddesc} - -\begin{methoddesc}[text-edit]{draw}{rect} -Pass a draw event to the text-edit block. -The rectangle specifies the redraw area. -\end{methoddesc} - -\begin{methoddesc}[text-edit]{event}{type, window, detail} -Pass an event gotten from -\function{stdwin.getevent()} -to the text-edit block. -Return true if the event was handled. -\end{methoddesc} - -\begin{methoddesc}[text-edit]{getfocus}{} -Return 2 integers representing the start and end positions of the -focus, usable as slice indices on the string returned by -\method{gettext()}. -\end{methoddesc} - -\begin{methoddesc}[text-edit]{getfocustext}{} -Return the text in the focus. -\end{methoddesc} - -\begin{methoddesc}[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.) -\end{methoddesc} - -\begin{methoddesc}[text-edit]{gettext}{} -Return the entire text buffer. -\end{methoddesc} - -\begin{methoddesc}[text-edit]{move}{rect} -Specify a new position for the text-edit block in the document. -\end{methoddesc} - -\begin{methoddesc}[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. -\end{methoddesc} - -\begin{methoddesc}[text-edit]{setfocus}{i, j} -Specify the new focus. -Out-of-bounds values are silently clipped. -\end{methoddesc} - -\begin{methoddesc}[text-edit]{settext}{str} -Replace the entire text buffer by the given string and set the focus -to \code{(0, 0)}. -\end{methoddesc} - -\begin{methoddesc}[text-edit]{setview}{rect} -Set the view rectangle to \var{rect}. If \var{rect} is \code{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. -\end{methoddesc} - -\begin{methoddesc}[text-edit]{close}{} -Discard the text-edit object. It should not be used again. -\end{methoddesc} - -\subsection{Example} -\nodename{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. - -\begin{verbatim} -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() -\end{verbatim} - - -\section{\module{stdwinevents} --- - Constants for use with \module{stdwin}} - -\declaremodule{standard}{stdwinevents} -\modulesynopsis{Constant definitions for use with \module{stdwin}} - - -This module defines constants used by STDWIN for event types -(\constant{WE_ACTIVATE} etc.), command codes (\constant{WC_LEFT} etc.) -and selection types (\constant{WS_PRIMARY} etc.). -Read the file for details. -Suggested usage is - -\begin{verbatim} ->>> from stdwinevents import * ->>> -\end{verbatim} - - -\section{\module{rect} --- - Functions for use with \module{stdwin}} - -\declaremodule{standard}{rect} -\modulesynopsis{Geometry-related utility function for use with - \module{stdwin}.} - - -This module contains useful operations on rectangles. -A rectangle is defined as in module \refmodule{stdwin}: -a pair of points, where a point is a pair of integers. -For example, the rectangle - -\begin{verbatim} -(10, 20), (90, 80) -\end{verbatim} - -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 \refmodule{stdwin}). - -The module defines the following objects: - -\begin{excdesc}{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. -\end{excdesc} - -\begin{datadesc}{empty} -The rectangle returned when some operations return an empty result. -This makes it possible to quickly check whether a result is empty: - -\begin{verbatim} ->>> 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 ->>> -\end{verbatim} -\end{datadesc} - -\begin{funcdesc}{is_empty}{r} -Returns true if the given rectangle is empty. -A rectangle -\code{(\var{left}, \var{top}), (\var{right}, \var{bottom})} -is empty if -\begin{math}\var{left} \geq \var{right}\end{math} or -\begin{math}\var{top} \geq \var{bottom}\end{math}. -\end{funcdesc} - -\begin{funcdesc}{intersect}{list} -Returns the intersection of all rectangles in the list argument. -It may also be called with a tuple argument. Raises -\exception{rect.error} if the list is empty. Returns -\constant{rect.empty} if the intersection of the rectangles is empty. -\end{funcdesc} - -\begin{funcdesc}{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 -\constant{rect.empty} if the list is empty or all its rectangles are -empty. -\end{funcdesc} - -\begin{funcdesc}{pointinrect}{point, rect} -Returns true if the point is inside the rectangle. By definition, a -point \code{(\var{h}, \var{v})} is inside a rectangle -\code{(\var{left}, \var{top}), (\var{right}, \var{bottom})} if -\begin{math}\var{left} \leq \var{h} < \var{right}\end{math} and -\begin{math}\var{top} \leq \var{v} < \var{bottom}\end{math}. -\end{funcdesc} - -\begin{funcdesc}{inset}{rect, (dh, dv)} -Returns a rectangle that lies inside the \var{rect} argument by -\var{dh} pixels horizontally and \var{dv} pixels vertically. If -\var{dh} or \var{dv} is negative, the result lies outside \var{rect}. -\end{funcdesc} - -\begin{funcdesc}{rect2geom}{rect} -Converts a rectangle to geometry representation: -\code{(\var{left}, \var{top}), (\var{width}, \var{height})}. -\end{funcdesc} - -\begin{funcdesc}{geom2rect}{geom} -Converts a rectangle given in geometry representation back to the -standard rectangle representation -\code{(\var{left}, \var{top}), (\var{right}, \var{bottom})}. -\end{funcdesc} |