[Python-3000-checkins] r63190 - in python/branches/py3k: Doc/library/aepack.rst Doc/library/aetools.rst Doc/library/aetypes.rst Doc/library/autogil.rst Doc/library/binhex.rst Doc/library/carbon.rst Doc/library/colorpicker.rst Doc/library/easydialogs.rst Doc/library/framework.rst Doc/library/ic.rst Doc/library/index.rst Doc/library/mac.rst Doc/library/macos.rst Doc/library/macosa.rst Doc/library/macostools.rst Doc/library/plistlib.rst Doc/library/undoc.rst Doc/using/mac.rst Lib/binhex.py Lib/plat-mac/Audio_mac.py Lib/plat-mac/Carbon Lib/plat-mac/EasyDialogs.py Lib/plat-mac/FrameWork.py Lib/plat-mac/MiniAEFrame.py Lib/plat-mac/PixMapWrapper.py Lib/plat-mac/aepack.py Lib/plat-mac/aetools.py Lib/plat-mac/aetypes.py Lib/plat-mac/applesingle.py Lib/plat-mac/appletrawmain.py Lib/plat-mac/appletrunner.py Lib/plat-mac/argvemulator.py Lib/plat-mac/bgenlocations.py Lib/plat-mac/buildtools.py Lib/plat-mac/bundlebuilder.py Lib/plat-mac/dialogs.rsrc Lib/plat-mac/errors.rsrc Lib/plat-mac/findertools.py Lib/plat-mac/gensuitemodule.py Lib/plat-mac/ic.py Lib/plat-mac/icopen.py Lib/plat-mac/lib-scriptpackages Lib/plat-mac/macerrors.py Lib/plat-mac/macostools.py Lib/plat-mac/macresource.py Lib/plat-mac/pimp.py Lib/plat-mac/terminalcommand.py Lib/plat-mac/videoreader.py Lib/plistlib.py Lib/test/test_aepack.py Lib/test/test_applesingle.py Lib/test/test_macostools.py Lib/test/test_scriptpackages.py Mac/Modules setup.py
benjamin.peterson
python-3000-checkins at python.org
Tue May 13 00:25:20 CEST 2008
Author: benjamin.peterson
Date: Tue May 13 00:25:16 2008
New Revision: 63190
Log:
Remove the Mac modules
Removed:
python/branches/py3k/Doc/library/aepack.rst
python/branches/py3k/Doc/library/aetools.rst
python/branches/py3k/Doc/library/aetypes.rst
python/branches/py3k/Doc/library/autogil.rst
python/branches/py3k/Doc/library/carbon.rst
python/branches/py3k/Doc/library/colorpicker.rst
python/branches/py3k/Doc/library/easydialogs.rst
python/branches/py3k/Doc/library/framework.rst
python/branches/py3k/Doc/library/ic.rst
python/branches/py3k/Doc/library/mac.rst
python/branches/py3k/Doc/library/macos.rst
python/branches/py3k/Doc/library/macosa.rst
python/branches/py3k/Doc/library/macostools.rst
python/branches/py3k/Lib/plat-mac/Audio_mac.py
python/branches/py3k/Lib/plat-mac/Carbon/
python/branches/py3k/Lib/plat-mac/EasyDialogs.py
python/branches/py3k/Lib/plat-mac/FrameWork.py
python/branches/py3k/Lib/plat-mac/MiniAEFrame.py
python/branches/py3k/Lib/plat-mac/PixMapWrapper.py
python/branches/py3k/Lib/plat-mac/aepack.py
python/branches/py3k/Lib/plat-mac/aetools.py
python/branches/py3k/Lib/plat-mac/aetypes.py
python/branches/py3k/Lib/plat-mac/applesingle.py
python/branches/py3k/Lib/plat-mac/appletrawmain.py
python/branches/py3k/Lib/plat-mac/appletrunner.py
python/branches/py3k/Lib/plat-mac/argvemulator.py
python/branches/py3k/Lib/plat-mac/bgenlocations.py
python/branches/py3k/Lib/plat-mac/buildtools.py
python/branches/py3k/Lib/plat-mac/bundlebuilder.py
python/branches/py3k/Lib/plat-mac/dialogs.rsrc
python/branches/py3k/Lib/plat-mac/errors.rsrc
python/branches/py3k/Lib/plat-mac/findertools.py
python/branches/py3k/Lib/plat-mac/gensuitemodule.py
python/branches/py3k/Lib/plat-mac/ic.py
python/branches/py3k/Lib/plat-mac/icopen.py
python/branches/py3k/Lib/plat-mac/lib-scriptpackages/
python/branches/py3k/Lib/plat-mac/macerrors.py
python/branches/py3k/Lib/plat-mac/macostools.py
python/branches/py3k/Lib/plat-mac/macresource.py
python/branches/py3k/Lib/plat-mac/pimp.py
python/branches/py3k/Lib/plat-mac/terminalcommand.py
python/branches/py3k/Lib/plat-mac/videoreader.py
python/branches/py3k/Lib/test/test_aepack.py
python/branches/py3k/Lib/test/test_applesingle.py
python/branches/py3k/Lib/test/test_macostools.py
python/branches/py3k/Lib/test/test_scriptpackages.py
python/branches/py3k/Mac/Modules/
Modified:
python/branches/py3k/Doc/library/binhex.rst
python/branches/py3k/Doc/library/index.rst
python/branches/py3k/Doc/library/plistlib.rst
python/branches/py3k/Doc/library/undoc.rst
python/branches/py3k/Doc/using/mac.rst
python/branches/py3k/Lib/binhex.py
python/branches/py3k/Lib/plistlib.py
python/branches/py3k/setup.py
Deleted: python/branches/py3k/Doc/library/aepack.rst
==============================================================================
--- python/branches/py3k/Doc/library/aepack.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,86 +0,0 @@
-
-:mod:`aepack` --- Conversion between Python variables and AppleEvent data containers
-====================================================================================
-
-.. module:: aepack
- :platform: Mac
- :synopsis: Conversion between Python variables and AppleEvent data containers.
-.. sectionauthor:: Vincent Marchetti <vincem at en.com>
-.. moduleauthor:: Jack Jansen
-
-The :mod:`aepack` module defines functions for converting (packing) Python
-variables to AppleEvent descriptors and back (unpacking). Within Python the
-AppleEvent descriptor is handled by Python objects of built-in type
-:class:`AEDesc`, defined in module :mod:`Carbon.AE`.
-
-The :mod:`aepack` module defines the following functions:
-
-
-.. function:: pack(x[, forcetype])
-
- Returns an :class:`AEDesc` object containing a conversion of Python value x. If
- *forcetype* is provided it specifies the descriptor type of the result.
- Otherwise, a default mapping of Python types to Apple Event descriptor types is
- used, as follows:
-
- +-----------------+-----------------------------------+
- | Python type | descriptor type |
- +=================+===================================+
- | :class:`FSSpec` | typeFSS |
- +-----------------+-----------------------------------+
- | :class:`FSRef` | typeFSRef |
- +-----------------+-----------------------------------+
- | :class:`Alias` | typeAlias |
- +-----------------+-----------------------------------+
- | integer | typeLong (32 bit integer) |
- +-----------------+-----------------------------------+
- | float | typeFloat (64 bit floating point) |
- +-----------------+-----------------------------------+
- | string | typeText |
- +-----------------+-----------------------------------+
- | unicode | typeUnicodeText |
- +-----------------+-----------------------------------+
- | list | typeAEList |
- +-----------------+-----------------------------------+
- | dictionary | typeAERecord |
- +-----------------+-----------------------------------+
- | instance | *see below* |
- +-----------------+-----------------------------------+
-
- If *x* is a Python instance then this function attempts to call an
- :meth:`__aepack__` method. This method should return an :class:`AEDesc` object.
-
- If the conversion *x* is not defined above, this function returns the Python
- string representation of a value (the repr() function) encoded as a text
- descriptor.
-
-
-.. function:: unpack(x[, formodulename])
-
- *x* must be an object of type :class:`AEDesc`. This function returns a Python
- object representation of the data in the Apple Event descriptor *x*. Simple
- AppleEvent data types (integer, text, float) are returned as their obvious
- Python counterparts. Apple Event lists are returned as Python lists, and the
- list elements are recursively unpacked. Object references (ex. ``line 3 of
- document 1``) are returned as instances of :class:`aetypes.ObjectSpecifier`,
- unless ``formodulename`` is specified. AppleEvent descriptors with descriptor
- type typeFSS are returned as :class:`FSSpec` objects. AppleEvent record
- descriptors are returned as Python dictionaries, with 4-character string keys
- and elements recursively unpacked.
-
- The optional ``formodulename`` argument is used by the stub packages generated
- by :mod:`gensuitemodule`, and ensures that the OSA classes for object specifiers
- are looked up in the correct module. This ensures that if, say, the Finder
- returns an object specifier for a window you get an instance of
- ``Finder.Window`` and not a generic ``aetypes.Window``. The former knows about
- all the properties and elements a window has in the Finder, while the latter
- knows no such things.
-
-
-.. seealso::
-
- Module :mod:`Carbon.AE`
- Built-in access to Apple Event Manager routines.
-
- Module :mod:`aetypes`
- Python definitions of codes for Apple Event descriptor types.
Deleted: python/branches/py3k/Doc/library/aetools.rst
==============================================================================
--- python/branches/py3k/Doc/library/aetools.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,84 +0,0 @@
-
-:mod:`aetools` --- OSA client support
-=====================================
-
-.. module:: aetools
- :platform: Mac
- :synopsis: Basic support for sending Apple Events
-.. sectionauthor:: Jack Jansen <Jack.Jansen at cwi.nl>
-.. moduleauthor:: Jack Jansen
-
-The :mod:`aetools` module contains the basic functionality on which Python
-AppleScript client support is built. It also imports and re-exports the core
-functionality of the :mod:`aetypes` and :mod:`aepack` modules. The stub packages
-generated by :mod:`gensuitemodule` import the relevant portions of
-:mod:`aetools`, so usually you do not need to import it yourself. The exception
-to this is when you cannot use a generated suite package and need lower-level
-access to scripting.
-
-The :mod:`aetools` module itself uses the AppleEvent support provided by the
-:mod:`Carbon.AE` module. This has one drawback: you need access to the window
-manager, see section :ref:`osx-gui-scripts` for details. This restriction may be
-lifted in future releases.
-
-The :mod:`aetools` module defines the following functions:
-
-
-.. function:: packevent(ae, parameters, attributes)
-
- Stores parameters and attributes in a pre-created ``Carbon.AE.AEDesc`` object.
- ``parameters`` and ``attributes`` are dictionaries mapping 4-character OSA
- parameter keys to Python objects. The objects are packed using
- ``aepack.pack()``.
-
-
-.. function:: unpackevent(ae[, formodulename])
-
- Recursively unpacks a ``Carbon.AE.AEDesc`` event to Python objects. The function
- returns the parameter dictionary and the attribute dictionary. The
- ``formodulename`` argument is used by generated stub packages to control where
- AppleScript classes are looked up.
-
-
-.. function:: keysubst(arguments, keydict)
-
- Converts a Python keyword argument dictionary ``arguments`` to the format
- required by ``packevent`` by replacing the keys, which are Python identifiers,
- by the four-character OSA keys according to the mapping specified in
- ``keydict``. Used by the generated suite packages.
-
-
-.. function:: enumsubst(arguments, key, edict)
-
- If the ``arguments`` dictionary contains an entry for ``key`` convert the value
- for that entry according to dictionary ``edict``. This converts human-readable
- Python enumeration names to the OSA 4-character codes. Used by the generated
- suite packages.
-
-The :mod:`aetools` module defines the following class:
-
-
-.. class:: TalkTo([signature=None, start=0, timeout=0])
-
- Base class for the proxy used to talk to an application. ``signature`` overrides
- the class attribute ``_signature`` (which is usually set by subclasses) and is
- the 4-char creator code defining the application to talk to. ``start`` can be
- set to true to enable running the application on class instantiation.
- ``timeout`` can be specified to change the default timeout used while waiting
- for an AppleEvent reply.
-
-
-.. method:: TalkTo._start()
-
- Test whether the application is running, and attempt to start it if not.
-
-
-.. method:: TalkTo.send(code, subcode[, parameters, attributes])
-
- Create the AppleEvent ``Carbon.AE.AEDesc`` for the verb with the OSA designation
- ``code, subcode`` (which are the usual 4-character strings), pack the
- ``parameters`` and ``attributes`` into it, send it to the target application,
- wait for the reply, unpack the reply with ``unpackevent`` and return the reply
- appleevent, the unpacked return values as a dictionary and the return
- attributes.
-
Deleted: python/branches/py3k/Doc/library/aetypes.rst
==============================================================================
--- python/branches/py3k/Doc/library/aetypes.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,148 +0,0 @@
-
-:mod:`aetypes` --- AppleEvent objects
-=====================================
-
-.. module:: aetypes
- :platform: Mac
- :synopsis: Python representation of the Apple Event Object Model.
-.. sectionauthor:: Vincent Marchetti <vincem at en.com>
-.. moduleauthor:: Jack Jansen
-
-The :mod:`aetypes` defines classes used to represent Apple Event data
-descriptors and Apple Event object specifiers.
-
-Apple Event data is contained in descriptors, and these descriptors are typed.
-For many descriptors the Python representation is simply the corresponding
-Python type: ``typeText`` in OSA is a Python string, ``typeFloat`` is a float,
-etc. For OSA types that have no direct Python counterpart this module declares
-classes. Packing and unpacking instances of these classes is handled
-automatically by :mod:`aepack`.
-
-An object specifier is essentially an address of an object implemented in a
-Apple Event server. An Apple Event specifier is used as the direct object for an
-Apple Event or as the argument of an optional parameter. The :mod:`aetypes`
-module contains the base classes for OSA classes and properties, which are used
-by the packages generated by :mod:`gensuitemodule` to populate the classes and
-properties in a given suite.
-
-For reasons of backward compatibility, and for cases where you need to script an
-application for which you have not generated the stub package this module also
-contains object specifiers for a number of common OSA classes such as
-``Document``, ``Window``, ``Character``, etc.
-
-The :mod:`AEObjects` module defines the following classes to represent Apple
-Event descriptor data:
-
-
-.. class:: Unknown(type, data)
-
- The representation of OSA descriptor data for which the :mod:`aepack` and
- :mod:`aetypes` modules have no support, i.e. anything that is not represented by
- the other classes here and that is not equivalent to a simple Python value.
-
-
-.. class:: Enum(enum)
-
- An enumeration value with the given 4-character string value.
-
-
-.. class:: InsertionLoc(of, pos)
-
- Position ``pos`` in object ``of``.
-
-
-.. class:: Boolean(bool)
-
- A boolean.
-
-
-.. class:: StyledText(style, text)
-
- Text with style information (font, face, etc) included.
-
-
-.. class:: AEText(script, style, text)
-
- Text with script system and style information included.
-
-
-.. class:: IntlText(script, language, text)
-
- Text with script system and language information included.
-
-
-.. class:: IntlWritingCode(script, language)
-
- Script system and language information.
-
-
-.. class:: QDPoint(v, h)
-
- A quickdraw point.
-
-
-.. class:: QDRectangle(v0, h0, v1, h1)
-
- A quickdraw rectangle.
-
-
-.. class:: RGBColor(r, g, b)
-
- A color.
-
-
-.. class:: Type(type)
-
- An OSA type value with the given 4-character name.
-
-
-.. class:: Keyword(name)
-
- An OSA keyword with the given 4-character name.
-
-
-.. class:: Range(start, stop)
-
- A range.
-
-
-.. class:: Ordinal(abso)
-
- Non-numeric absolute positions, such as ``"firs"``, first, or ``"midd"``,
- middle.
-
-
-.. class:: Logical(logc, term)
-
- The logical expression of applying operator ``logc`` to ``term``.
-
-
-.. class:: Comparison(obj1, relo, obj2)
-
- The comparison ``relo`` of ``obj1`` to ``obj2``.
-
-The following classes are used as base classes by the generated stub packages to
-represent AppleScript classes and properties in Python:
-
-
-.. class:: ComponentItem(which[, fr])
-
- Abstract baseclass for an OSA class. The subclass should set the class attribute
- ``want`` to the 4-character OSA class code. Instances of subclasses of this
- class are equivalent to AppleScript Object Specifiers. Upon instantiation you
- should pass a selector in ``which``, and optionally a parent object in ``fr``.
-
-
-.. class:: NProperty(fr)
-
- Abstract baseclass for an OSA property. The subclass should set the class
- attributes ``want`` and ``which`` to designate which property we are talking
- about. Instances of subclasses of this class are Object Specifiers.
-
-
-.. class:: ObjectSpecifier(want, form, seld[, fr])
-
- Base class of ``ComponentItem`` and ``NProperty``, a general OSA Object
- Specifier. See the Apple Open Scripting Architecture documentation for the
- parameters. Note that this class is not abstract.
-
Deleted: python/branches/py3k/Doc/library/autogil.rst
==============================================================================
--- python/branches/py3k/Doc/library/autogil.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,30 +0,0 @@
-
-:mod:`autoGIL` --- Global Interpreter Lock handling in event loops
-==================================================================
-
-.. module:: autoGIL
- :platform: Mac
- :synopsis: Global Interpreter Lock handling in event loops.
-.. moduleauthor:: Just van Rossum <just at letterror.com>
-
-
-The :mod:`autoGIL` module provides a function :func:`installAutoGIL` that
-automatically locks and unlocks Python's :term:`Global Interpreter Lock` when
-running an event loop.
-
-
-.. exception:: AutoGILError
-
- Raised if the observer callback cannot be installed, for example because the
- current thread does not have a run loop.
-
-
-.. function:: installAutoGIL()
-
- Install an observer callback in the event loop (CFRunLoop) for the current
- thread, that will lock and unlock the Global Interpreter Lock (GIL) at
- appropriate times, allowing other Python threads to run while the event loop is
- idle.
-
- Availability: OSX 10.1 or later.
-
Modified: python/branches/py3k/Doc/library/binhex.rst
==============================================================================
--- python/branches/py3k/Doc/library/binhex.rst (original)
+++ python/branches/py3k/Doc/library/binhex.rst Tue May 13 00:25:16 2008
@@ -7,9 +7,7 @@
This module encodes and decodes files in binhex4 format, a format allowing
-representation of Macintosh files in ASCII. On the Macintosh, both forks of a
-file and the finder information are encoded (or decoded), on other platforms
-only the data fork is handled.
+representation of Macintosh files in ASCII. Only the data fork is handled.
The :mod:`binhex` module defines the following functions:
Deleted: python/branches/py3k/Doc/library/carbon.rst
==============================================================================
--- python/branches/py3k/Doc/library/carbon.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,288 +0,0 @@
-
-.. _toolbox:
-
-*********************
-MacOS Toolbox Modules
-*********************
-
-There are a set of modules that provide interfaces to various MacOS toolboxes.
-If applicable the module will define a number of Python objects for the various
-structures declared by the toolbox, and operations will be implemented as
-methods of the object. Other operations will be implemented as functions in the
-module. Not all operations possible in C will also be possible in Python
-(callbacks are often a problem), and parameters will occasionally be different
-in Python (input and output buffers, especially). All methods and functions
-have a :attr:`__doc__` string describing their arguments and return values, and
-for additional description you are referred to `Inside Macintosh
-<http://developer.apple.com/documentation/macos8/mac8.html>`_ or similar works.
-
-These modules all live in a package called :mod:`Carbon`. Despite that name they
-are not all part of the Carbon framework: CF is really in the CoreFoundation
-framework and Qt is in the QuickTime framework. The normal use pattern is ::
-
- from Carbon import AE
-
-**Warning!** These modules are not yet documented. If you wish to contribute
-documentation of any of these modules, please get in touch with docs at python.org.
-
-
-:mod:`Carbon.AE` --- Apple Events
-=================================
-
-.. module:: Carbon.AE
- :platform: Mac
- :synopsis: Interface to the Apple Events toolbox.
-
-
-
-:mod:`Carbon.AH` --- Apple Help
-===============================
-
-.. module:: Carbon.AH
- :platform: Mac
- :synopsis: Interface to the Apple Help manager.
-
-
-
-:mod:`Carbon.App` --- Appearance Manager
-========================================
-
-.. module:: Carbon.App
- :platform: Mac
- :synopsis: Interface to the Appearance Manager.
-
-
-
-:mod:`Carbon.CF` --- Core Foundation
-====================================
-
-.. module:: Carbon.CF
- :platform: Mac
- :synopsis: Interface to the Core Foundation.
-
-
-The ``CFBase``, ``CFArray``, ``CFData``, ``CFDictionary``, ``CFString`` and
-``CFURL`` objects are supported, some only partially.
-
-
-:mod:`Carbon.CG` --- Core Graphics
-==================================
-
-.. module:: Carbon.CG
- :platform: Mac
- :synopsis: Interface to Core Graphics.
-
-
-
-:mod:`Carbon.CarbonEvt` --- Carbon Event Manager
-================================================
-
-.. module:: Carbon.CarbonEvt
- :platform: Mac
- :synopsis: Interface to the Carbon Event Manager.
-
-
-
-:mod:`Carbon.Cm` --- Component Manager
-======================================
-
-.. module:: Carbon.Cm
- :platform: Mac
- :synopsis: Interface to the Component Manager.
-
-
-
-:mod:`Carbon.Ctl` --- Control Manager
-=====================================
-
-.. module:: Carbon.Ctl
- :platform: Mac
- :synopsis: Interface to the Control Manager.
-
-
-
-:mod:`Carbon.Dlg` --- Dialog Manager
-====================================
-
-.. module:: Carbon.Dlg
- :platform: Mac
- :synopsis: Interface to the Dialog Manager.
-
-
-
-:mod:`Carbon.Evt` --- Event Manager
-===================================
-
-.. module:: Carbon.Evt
- :platform: Mac
- :synopsis: Interface to the classic Event Manager.
-
-
-
-:mod:`Carbon.Fm` --- Font Manager
-=================================
-
-.. module:: Carbon.Fm
- :platform: Mac
- :synopsis: Interface to the Font Manager.
-
-
-
-:mod:`Carbon.Folder` --- Folder Manager
-=======================================
-
-.. module:: Carbon.Folder
- :platform: Mac
- :synopsis: Interface to the Folder Manager.
-
-
-
-:mod:`Carbon.Help` --- Help Manager
-===================================
-
-.. module:: Carbon.Help
- :platform: Mac
- :synopsis: Interface to the Carbon Help Manager.
-
-
-
-:mod:`Carbon.List` --- List Manager
-===================================
-
-.. module:: Carbon.List
- :platform: Mac
- :synopsis: Interface to the List Manager.
-
-
-
-:mod:`Carbon.Menu` --- Menu Manager
-===================================
-
-.. module:: Carbon.Menu
- :platform: Mac
- :synopsis: Interface to the Menu Manager.
-
-
-
-:mod:`Carbon.Mlte` --- MultiLingual Text Editor
-===============================================
-
-.. module:: Carbon.Mlte
- :platform: Mac
- :synopsis: Interface to the MultiLingual Text Editor.
-
-
-
-:mod:`Carbon.Qd` --- QuickDraw
-==============================
-
-.. module:: Carbon.Qd
- :platform: Mac
- :synopsis: Interface to the QuickDraw toolbox.
-
-
-
-:mod:`Carbon.Qdoffs` --- QuickDraw Offscreen
-============================================
-
-.. module:: Carbon.Qdoffs
- :platform: Mac
- :synopsis: Interface to the QuickDraw Offscreen APIs.
-
-
-
-:mod:`Carbon.Qt` --- QuickTime
-==============================
-
-.. module:: Carbon.Qt
- :platform: Mac
- :synopsis: Interface to the QuickTime toolbox.
-
-
-
-:mod:`Carbon.Res` --- Resource Manager and Handles
-==================================================
-
-.. module:: Carbon.Res
- :platform: Mac
- :synopsis: Interface to the Resource Manager and Handles.
-
-
-
-:mod:`Carbon.Scrap` --- Scrap Manager
-=====================================
-
-.. module:: Carbon.Scrap
- :platform: Mac
- :synopsis: The Scrap Manager provides basic services for implementing cut & paste and
- clipboard operations.
-
-
-This module is only fully available on MacOS9 and earlier under classic PPC
-MacPython. Very limited functionality is available under Carbon MacPython.
-
-.. index:: single: Scrap Manager
-
-The Scrap Manager supports the simplest form of cut & paste operations on the
-Macintosh. It can be use for both inter- and intra-application clipboard
-operations.
-
-The :mod:`Scrap` module provides low-level access to the functions of the Scrap
-Manager. It contains the following functions:
-
-
-.. function:: InfoScrap()
-
- Return current information about the scrap. The information is encoded as a
- tuple containing the fields ``(size, handle, count, state, path)``.
-
- +----------+---------------------------------------------+
- | Field | Meaning |
- +==========+=============================================+
- | *size* | Size of the scrap in bytes. |
- +----------+---------------------------------------------+
- | *handle* | Resource object representing the scrap. |
- +----------+---------------------------------------------+
- | *count* | Serial number of the scrap contents. |
- +----------+---------------------------------------------+
- | *state* | Integer; positive if in memory, ``0`` if on |
- | | disk, negative if uninitialized. |
- +----------+---------------------------------------------+
- | *path* | Filename of the scrap when stored on disk. |
- +----------+---------------------------------------------+
-
-
-.. seealso::
-
- `Scrap Manager <http://developer.apple.com/documentation/mac/MoreToolbox/MoreToolbox-109.html>`_
- Apple's documentation for the Scrap Manager gives a lot of useful information
- about using the Scrap Manager in applications.
-
-
-
-:mod:`Carbon.Snd` --- Sound Manager
-===================================
-
-.. module:: Carbon.Snd
- :platform: Mac
- :synopsis: Interface to the Sound Manager.
-
-
-
-:mod:`Carbon.TE` --- TextEdit
-=============================
-
-.. module:: Carbon.TE
- :platform: Mac
- :synopsis: Interface to TextEdit.
-
-
-
-:mod:`Carbon.Win` --- Window Manager
-====================================
-
-.. module:: Carbon.Win
- :platform: Mac
- :synopsis: Interface to the Window Manager.
-
-
Deleted: python/branches/py3k/Doc/library/colorpicker.rst
==============================================================================
--- python/branches/py3k/Doc/library/colorpicker.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,23 +0,0 @@
-
-:mod:`ColorPicker` --- Color selection dialog
-=============================================
-
-.. module:: ColorPicker
- :platform: Mac
- :synopsis: Interface to the standard color selection dialog.
-.. moduleauthor:: Just van Rossum <just at letterror.com>
-.. sectionauthor:: Fred L. Drake, Jr. <fdrake at acm.org>
-
-
-The :mod:`ColorPicker` module provides access to the standard color picker
-dialog.
-
-
-.. function:: GetColor(prompt, rgb)
-
- Show a standard color selection dialog and allow the user to select a color.
- The user is given instruction by the *prompt* string, and the default color is
- set to *rgb*. *rgb* must be a tuple giving the red, green, and blue components
- of the color. :func:`GetColor` returns a tuple giving the user's selected color
- and a flag indicating whether they accepted the selection of cancelled.
-
Deleted: python/branches/py3k/Doc/library/easydialogs.rst
==============================================================================
--- python/branches/py3k/Doc/library/easydialogs.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,202 +0,0 @@
-
-:mod:`EasyDialogs` --- Basic Macintosh dialogs
-==============================================
-
-.. module:: EasyDialogs
- :platform: Mac
- :synopsis: Basic Macintosh dialogs.
-
-
-The :mod:`EasyDialogs` module contains some simple dialogs for the Macintosh.
-All routines take an optional resource ID parameter *id* with which one can
-override the :const:`DLOG` resource used for the dialog, provided that the
-dialog items correspond (both type and item number) to those in the default
-:const:`DLOG` resource. See source code for details.
-
-The :mod:`EasyDialogs` module defines the following functions:
-
-
-.. function:: Message(str[, id[, ok]])
-
- Displays a modal dialog with the message text *str*, which should be at most 255
- characters long. The button text defaults to "OK", but is set to the string
- argument *ok* if the latter is supplied. Control is returned when the user
- clicks the "OK" button.
-
-
-.. function:: AskString(prompt[, default[, id[, ok[, cancel]]]])
-
- Asks the user to input a string value via a modal dialog. *prompt* is the prompt
- message, and the optional *default* supplies the initial value for the string
- (otherwise ``""`` is used). The text of the "OK" and "Cancel" buttons can be
- changed with the *ok* and *cancel* arguments. All strings can be at most 255
- bytes long. :func:`AskString` returns the string entered or :const:`None` in
- case the user cancelled.
-
-
-.. function:: AskPassword(prompt[, default[, id[, ok[, cancel]]]])
-
- Asks the user to input a string value via a modal dialog. Like
- :func:`AskString`, but with the text shown as bullets. The arguments have the
- same meaning as for :func:`AskString`.
-
-
-.. function:: AskYesNoCancel(question[, default[, yes[, no[, cancel[, id]]]]])
-
- Presents a dialog with prompt *question* and three buttons labelled "Yes", "No",
- and "Cancel". Returns ``1`` for "Yes", ``0`` for "No" and ``-1`` for "Cancel".
- The value of *default* (or ``0`` if *default* is not supplied) is returned when
- the :kbd:`RETURN` key is pressed. The text of the buttons can be changed with
- the *yes*, *no*, and *cancel* arguments; to prevent a button from appearing,
- supply ``""`` for the corresponding argument.
-
-
-.. function:: ProgressBar([title[, maxval[, label[, id]]]])
-
- Displays a modeless progress-bar dialog. This is the constructor for the
- :class:`ProgressBar` class described below. *title* is the text string displayed
- (default "Working..."), *maxval* is the value at which progress is complete
- (default ``0``, indicating that an indeterminate amount of work remains to be
- done), and *label* is the text that is displayed above the progress bar itself.
-
-
-.. function:: GetArgv([optionlist[ commandlist[, addoldfile[, addnewfile[, addfolder[, id]]]]]])
-
- Displays a dialog which aids the user in constructing a command-line argument
- list. Returns the list in ``sys.argv`` format, suitable for passing as an
- argument to :func:`getopt.getopt`. *addoldfile*, *addnewfile*, and *addfolder*
- are boolean arguments. When nonzero, they enable the user to insert into the
- command line paths to an existing file, a (possibly) not-yet-existent file, and
- a folder, respectively. (Note: Option arguments must appear in the command line
- before file and folder arguments in order to be recognized by
- :func:`getopt.getopt`.) Arguments containing spaces can be specified by
- enclosing them within single or double quotes. A :exc:`SystemExit` exception is
- raised if the user presses the "Cancel" button.
-
- *optionlist* is a list that determines a popup menu from which the allowed
- options are selected. Its items can take one of two forms: *optstr* or
- ``(optstr, descr)``. When present, *descr* is a short descriptive string that
- is displayed in the dialog while this option is selected in the popup menu. The
- correspondence between *optstr*\s and command-line arguments is:
-
- +----------------------+------------------------------------------+
- | *optstr* format | Command-line format |
- +======================+==========================================+
- | ``x`` | :option:`-x` (short option) |
- +----------------------+------------------------------------------+
- | ``x:`` or ``x=`` | :option:`-x` (short option with value) |
- +----------------------+------------------------------------------+
- | ``xyz`` | :option:`--xyz` (long option) |
- +----------------------+------------------------------------------+
- | ``xyz:`` or ``xyz=`` | :option:`--xyz` (long option with value) |
- +----------------------+------------------------------------------+
-
- *commandlist* is a list of items of the form *cmdstr* or ``(cmdstr, descr)``,
- where *descr* is as above. The *cmdstr*s will appear in a popup menu. When
- chosen, the text of *cmdstr* will be appended to the command line as is, except
- that a trailing ``':'`` or ``'='`` (if present) will be trimmed off.
-
-
-.. function:: AskFileForOpen( [message] [, typeList] [, defaultLocation] [, defaultOptionFlags] [, location] [, clientName] [, windowTitle] [, actionButtonLabel] [, cancelButtonLabel] [, preferenceKey] [, popupExtension] [, eventProc] [, previewProc] [, filterProc] [, wanted] )
-
- Post a dialog asking the user for a file to open, and return the file selected
- or :const:`None` if the user cancelled. *message* is a text message to display,
- *typeList* is a list of 4-char filetypes allowable, *defaultLocation* is the
- pathname, :class:`FSSpec` or :class:`FSRef` of the folder to show initially,
- *location* is the ``(x, y)`` position on the screen where the dialog is shown,
- *actionButtonLabel* is a string to show instead of "Open" in the OK button,
- *cancelButtonLabel* is a string to show instead of "Cancel" in the cancel
- button, *wanted* is the type of value wanted as a return: :class:`str`,
- :class:`FSSpec`, :class:`FSRef` and subtypes thereof are
- acceptable.
-
- .. index:: single: Navigation Services
-
- For a description of the other arguments please see the Apple Navigation
- Services documentation and the :mod:`EasyDialogs` source code.
-
-
-.. function:: AskFileForSave( [message] [, savedFileName] [, defaultLocation] [, defaultOptionFlags] [, location] [, clientName] [, windowTitle] [, actionButtonLabel] [, cancelButtonLabel] [, preferenceKey] [, popupExtension] [, fileType] [, fileCreator] [, eventProc] [, wanted] )
-
- Post a dialog asking the user for a file to save to, and return the file
- selected or :const:`None` if the user cancelled. *savedFileName* is the default
- for the file name to save to (the return value). See :func:`AskFileForOpen` for
- a description of the other arguments.
-
-
-.. function:: AskFolder( [message] [, defaultLocation] [, defaultOptionFlags] [, location] [, clientName] [, windowTitle] [, actionButtonLabel] [, cancelButtonLabel] [, preferenceKey] [, popupExtension] [, eventProc] [, filterProc] [, wanted] )
-
- Post a dialog asking the user to select a folder, and return the folder selected
- or :const:`None` if the user cancelled. See :func:`AskFileForOpen` for a
- description of the arguments.
-
-
-.. seealso::
-
- `Navigation Services Reference <http://developer.apple.com/documentation/Carbon/Reference/Navigation_Services_Ref/>`_
- Programmer's reference documentation for the Navigation Services, a part of the
- Carbon framework.
-
-
-.. _progressbar-objects:
-
-ProgressBar Objects
--------------------
-
-:class:`ProgressBar` objects provide support for modeless progress-bar dialogs.
-Both determinate (thermometer style) and indeterminate (barber-pole style)
-progress bars are supported. The bar will be determinate if its maximum value
-is greater than zero; otherwise it will be indeterminate.
-
-The dialog is displayed immediately after creation. If the dialog's "Cancel"
-button is pressed, or if :kbd:`Cmd-.` or :kbd:`ESC` is typed, the dialog window
-is hidden and :exc:`KeyboardInterrupt` is raised (but note that this response
-does not occur until the progress bar is next updated, typically via a call to
-:meth:`inc` or :meth:`set`). Otherwise, the bar remains visible until the
-:class:`ProgressBar` object is discarded.
-
-:class:`ProgressBar` objects possess the following attributes and methods:
-
-
-.. attribute:: ProgressBar.curval
-
- The current value (of type integer) of the progress bar. The
- normal access methods coerce :attr:`curval` between ``0`` and :attr:`maxval`.
- This attribute should not be altered directly.
-
-
-.. attribute:: ProgressBar.maxval
-
- The maximum value (of type integer) of the progress bar; the
- progress bar (thermometer style) is full when :attr:`curval` equals
- :attr:`maxval`. If :attr:`maxval` is ``0``, the bar will be indeterminate
- (barber-pole). This attribute should not be altered directly.
-
-
-.. method:: ProgressBar.title([newstr])
-
- Sets the text in the title bar of the progress dialog to *newstr*.
-
-
-.. method:: ProgressBar.label([newstr])
-
- Sets the text in the progress box of the progress dialog to *newstr*.
-
-
-.. method:: ProgressBar.set(value[, max])
-
- Sets the progress bar's :attr:`curval` to *value*, and also :attr:`maxval` to
- *max* if the latter is provided. *value* is first coerced between 0 and
- :attr:`maxval`. The thermometer bar is updated to reflect the changes,
- including a change from indeterminate to determinate or vice versa.
-
-
-.. method:: ProgressBar.inc([n])
-
- Increments the progress bar's :attr:`curval` by *n*, or by ``1`` if *n* is not
- provided. (Note that *n* may be negative, in which case the effect is a
- decrement.) The progress bar is updated to reflect the change. If the bar is
- indeterminate, this causes one "spin" of the barber pole. The resulting
- :attr:`curval` is coerced between 0 and :attr:`maxval` if incrementing causes it
- to fall outside this range.
-
Deleted: python/branches/py3k/Doc/library/framework.rst
==============================================================================
--- python/branches/py3k/Doc/library/framework.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,335 +0,0 @@
-
-:mod:`FrameWork` --- Interactive application framework
-======================================================
-
-.. module:: FrameWork
- :platform: Mac
- :synopsis: Interactive application framework.
-
-
-The :mod:`FrameWork` module contains classes that together provide a framework
-for an interactive Macintosh application. The programmer builds an application
-by creating subclasses that override various methods of the bases classes,
-thereby implementing the functionality wanted. Overriding functionality can
-often be done on various different levels, i.e. to handle clicks in a single
-dialog window in a non-standard way it is not necessary to override the complete
-event handling.
-
-Work on the :mod:`FrameWork` has pretty much stopped, now that :mod:`PyObjC` is
-available for full Cocoa access from Python, and the documentation describes
-only the most important functionality, and not in the most logical manner at
-that. Examine the source or the examples for more details. The following are
-some comments posted on the MacPython newsgroup about the strengths and
-limitations of :mod:`FrameWork`:
-
-
-.. epigraph::
-
- The strong point of :mod:`FrameWork` is that it allows you to break into the
- control-flow at many different places. :mod:`W`, for instance, uses a different
- way to enable/disable menus and that plugs right in leaving the rest intact.
- The weak points of :mod:`FrameWork` are that it has no abstract command
- interface (but that shouldn't be difficult), that its dialog support is minimal
- and that its control/toolbar support is non-existent.
-
-The :mod:`FrameWork` module defines the following functions:
-
-
-.. function:: Application()
-
- An object representing the complete application. See below for a description of
- the methods. The default :meth:`__init__` routine creates an empty window
- dictionary and a menu bar with an apple menu.
-
-
-.. function:: MenuBar()
-
- An object representing the menubar. This object is usually not created by the
- user.
-
-
-.. function:: Menu(bar, title[, after])
-
- An object representing a menu. Upon creation you pass the ``MenuBar`` the menu
- appears in, the *title* string and a position (1-based) *after* where the menu
- should appear (default: at the end).
-
-
-.. function:: MenuItem(menu, title[, shortcut, callback])
-
- Create a menu item object. The arguments are the menu to create, the item title
- string and optionally the keyboard shortcut and a callback routine. The callback
- is called with the arguments menu-id, item number within menu (1-based), current
- front window and the event record.
-
- Instead of a callable object the callback can also be a string. In this case
- menu selection causes the lookup of a method in the topmost window and the
- application. The method name is the callback string with ``'domenu_'``
- prepended.
-
- Calling the ``MenuBar`` :meth:`fixmenudimstate` method sets the correct dimming
- for all menu items based on the current front window.
-
-
-.. function:: Separator(menu)
-
- Add a separator to the end of a menu.
-
-
-.. function:: SubMenu(menu, label)
-
- Create a submenu named *label* under menu *menu*. The menu object is returned.
-
-
-.. function:: Window(parent)
-
- Creates a (modeless) window. *Parent* is the application object to which the
- window belongs. The window is not displayed until later.
-
-
-.. function:: DialogWindow(parent)
-
- Creates a modeless dialog window.
-
-
-.. function:: windowbounds(width, height)
-
- Return a ``(left, top, right, bottom)`` tuple suitable for creation of a window
- of given width and height. The window will be staggered with respect to previous
- windows, and an attempt is made to keep the whole window on-screen. However, the
- window will however always be the exact size given, so parts may be offscreen.
-
-
-.. function:: setwatchcursor()
-
- Set the mouse cursor to a watch.
-
-
-.. function:: setarrowcursor()
-
- Set the mouse cursor to an arrow.
-
-
-.. _application-objects:
-
-Application Objects
--------------------
-
-Application objects have the following methods, among others:
-
-
-.. method:: Application.makeusermenus()
-
- Override this method if you need menus in your application. Append the menus to
- the attribute :attr:`menubar`.
-
-
-.. method:: Application.getabouttext()
-
- Override this method to return a text string describing your application.
- Alternatively, override the :meth:`do_about` method for more elaborate "about"
- messages.
-
-
-.. method:: Application.mainloop([mask[, wait]])
-
- This routine is the main event loop, call it to set your application rolling.
- *Mask* is the mask of events you want to handle, *wait* is the number of ticks
- you want to leave to other concurrent application (default 0, which is probably
- not a good idea). While raising *self* to exit the mainloop is still supported
- it is not recommended: call ``self._quit()`` instead.
-
- The event loop is split into many small parts, each of which can be overridden.
- The default methods take care of dispatching events to windows and dialogs,
- handling drags and resizes, Apple Events, events for non-FrameWork windows, etc.
-
- In general, all event handlers should return ``1`` if the event is fully handled
- and ``0`` otherwise (because the front window was not a FrameWork window, for
- instance). This is needed so that update events and such can be passed on to
- other windows like the Sioux console window. Calling :func:`MacOS.HandleEvent`
- is not allowed within *our_dispatch* or its callees, since this may result in an
- infinite loop if the code is called through the Python inner-loop event handler.
-
-
-.. method:: Application.asyncevents(onoff)
-
- Call this method with a nonzero parameter to enable asynchronous event handling.
- This will tell the inner interpreter loop to call the application event handler
- *async_dispatch* whenever events are available. This will cause FrameWork window
- updates and the user interface to remain working during long computations, but
- will slow the interpreter down and may cause surprising results in non-reentrant
- code (such as FrameWork itself). By default *async_dispatch* will immediately
- call *our_dispatch* but you may override this to handle only certain events
- asynchronously. Events you do not handle will be passed to Sioux and such.
-
- The old on/off value is returned.
-
-
-.. method:: Application._quit()
-
- Terminate the running :meth:`mainloop` call at the next convenient moment.
-
-
-.. method:: Application.do_char(c, event)
-
- The user typed character *c*. The complete details of the event can be found in
- the *event* structure. This method can also be provided in a ``Window`` object,
- which overrides the application-wide handler if the window is frontmost.
-
-
-.. method:: Application.do_dialogevent(event)
-
- Called early in the event loop to handle modeless dialog events. The default
- method simply dispatches the event to the relevant dialog (not through the
- ``DialogWindow`` object involved). Override if you need special handling of
- dialog events (keyboard shortcuts, etc).
-
-
-.. method:: Application.idle(event)
-
- Called by the main event loop when no events are available. The null-event is
- passed (so you can look at mouse position, etc).
-
-
-.. _window-objects:
-
-Window Objects
---------------
-
-Window objects have the following methods, among others:
-
-
-.. method:: Window.open()
-
- Override this method to open a window. Store the MacOS window-id in
- :attr:`self.wid` and call the :meth:`do_postopen` method to register the window
- with the parent application.
-
-
-.. method:: Window.close()
-
- Override this method to do any special processing on window close. Call the
- :meth:`do_postclose` method to cleanup the parent state.
-
-
-.. method:: Window.do_postresize(width, height, macoswindowid)
-
- Called after the window is resized. Override if more needs to be done than
- calling ``InvalRect``.
-
-
-.. method:: Window.do_contentclick(local, modifiers, event)
-
- The user clicked in the content part of a window. The arguments are the
- coordinates (window-relative), the key modifiers and the raw event.
-
-
-.. method:: Window.do_update(macoswindowid, event)
-
- An update event for the window was received. Redraw the window.
-
-
-.. method:: Window.do_activate(activate, event)
-
- The window was activated (``activate == 1``) or deactivated (``activate == 0``).
- Handle things like focus highlighting, etc.
-
-
-.. _controlswindow-object:
-
-ControlsWindow Object
----------------------
-
-ControlsWindow objects have the following methods besides those of ``Window``
-objects:
-
-
-.. method:: ControlsWindow.do_controlhit(window, control, pcode, event)
-
- Part *pcode* of control *control* was hit by the user. Tracking and such has
- already been taken care of.
-
-
-.. _scrolledwindow-object:
-
-ScrolledWindow Object
----------------------
-
-ScrolledWindow objects are ControlsWindow objects with the following extra
-methods:
-
-
-.. method:: ScrolledWindow.scrollbars([wantx[, wanty]])
-
- Create (or destroy) horizontal and vertical scrollbars. The arguments specify
- which you want (default: both). The scrollbars always have minimum ``0`` and
- maximum ``32767``.
-
-
-.. method:: ScrolledWindow.getscrollbarvalues()
-
- You must supply this method. It should return a tuple ``(x, y)`` giving the
- current position of the scrollbars (between ``0`` and ``32767``). You can return
- ``None`` for either to indicate the whole document is visible in that direction.
-
-
-.. method:: ScrolledWindow.updatescrollbars()
-
- Call this method when the document has changed. It will call
- :meth:`getscrollbarvalues` and update the scrollbars.
-
-
-.. method:: ScrolledWindow.scrollbar_callback(which, what, value)
-
- Supplied by you and called after user interaction. *which* will be ``'x'`` or
- ``'y'``, *what* will be ``'-'``, ``'--'``, ``'set'``, ``'++'`` or ``'+'``. For
- ``'set'``, *value* will contain the new scrollbar position.
-
-
-.. method:: ScrolledWindow.scalebarvalues(absmin, absmax, curmin, curmax)
-
- Auxiliary method to help you calculate values to return from
- :meth:`getscrollbarvalues`. You pass document minimum and maximum value and
- topmost (leftmost) and bottommost (rightmost) visible values and it returns the
- correct number or ``None``.
-
-
-.. method:: ScrolledWindow.do_activate(onoff, event)
-
- Takes care of dimming/highlighting scrollbars when a window becomes frontmost.
- If you override this method, call this one at the end of your method.
-
-
-.. method:: ScrolledWindow.do_postresize(width, height, window)
-
- Moves scrollbars to the correct position. Call this method initially if you
- override it.
-
-
-.. method:: ScrolledWindow.do_controlhit(window, control, pcode, event)
-
- Handles scrollbar interaction. If you override it call this method first, a
- nonzero return value indicates the hit was in the scrollbars and has been
- handled.
-
-
-.. _dialogwindow-objects:
-
-DialogWindow Objects
---------------------
-
-DialogWindow objects have the following methods besides those of ``Window``
-objects:
-
-
-.. method:: DialogWindow.open(resid)
-
- Create the dialog window, from the DLOG resource with id *resid*. The dialog
- object is stored in :attr:`self.wid`.
-
-
-.. method:: DialogWindow.do_itemhit(item, event)
-
- Item number *item* was hit. You are responsible for redrawing toggle buttons,
- etc.
-
Deleted: python/branches/py3k/Doc/library/ic.rst
==============================================================================
--- python/branches/py3k/Doc/library/ic.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,119 +0,0 @@
-
-:mod:`ic` --- Access to the Mac OS X Internet Config
-====================================================
-
-.. module:: ic
- :platform: Mac
- :synopsis: Access to the Mac OS X Internet Config.
-
-
-This module provides access to various internet-related preferences set through
-:program:`System Preferences` or the :program:`Finder`.
-
-.. index:: module: icglue
-
-There is a low-level companion module :mod:`icglue` which provides the basic
-Internet Config access functionality. This low-level module is not documented,
-but the docstrings of the routines document the parameters and the routine names
-are the same as for the Pascal or C API to Internet Config, so the standard IC
-programmers' documentation can be used if this module is needed.
-
-The :mod:`ic` module defines the :exc:`error` exception and symbolic names for
-all error codes Internet Config can produce; see the source for details.
-
-
-.. exception:: error
-
- Exception raised on errors in the :mod:`ic` module.
-
-The :mod:`ic` module defines the following class and function:
-
-
-.. class:: IC([signature[, ic]])
-
- Create an Internet Config object. The signature is a 4-character creator code of
- the current application (default ``'Pyth'``) which may influence some of ICs
- settings. The optional *ic* argument is a low-level ``icglue.icinstance``
- created beforehand, this may be useful if you want to get preferences from a
- different config file, etc.
-
-
-.. function:: launchurl(url[, hint])
- parseurl(data[, start[, end[, hint]]])
- mapfile(file)
- maptypecreator(type, creator[, filename])
- settypecreator(file)
-
- These functions are "shortcuts" to the methods of the same name, described
- below.
-
-
-IC Objects
-----------
-
-:class:`IC` objects have a mapping interface, hence to obtain the mail address
-you simply get ``ic['MailAddress']``. Assignment also works, and changes the
-option in the configuration file.
-
-The module knows about various datatypes, and converts the internal IC
-representation to a "logical" Python data structure. Running the :mod:`ic`
-module standalone will run a test program that lists all keys and values in your
-IC database, this will have to serve as documentation.
-
-If the module does not know how to represent the data it returns an instance of
-the ``ICOpaqueData`` type, with the raw data in its :attr:`data` attribute.
-Objects of this type are also acceptable values for assignment.
-
-Besides the dictionary interface, :class:`IC` objects have the following
-methods:
-
-
-.. method:: IC.launchurl(url[, hint])
-
- Parse the given URL, launch the correct application and pass it the URL. The
- optional *hint* can be a scheme name such as ``'mailto:'``, in which case
- incomplete URLs are completed with this scheme. If *hint* is not provided,
- incomplete URLs are invalid.
-
-
-.. method:: IC.parseurl(data[, start[, end[, hint]]])
-
- Find an URL somewhere in *data* and return start position, end position and the
- URL. The optional *start* and *end* can be used to limit the search, so for
- instance if a user clicks in a long text field you can pass the whole text field
- and the click-position in *start* and this routine will return the whole URL in
- which the user clicked. As above, *hint* is an optional scheme used to complete
- incomplete URLs.
-
-
-.. method:: IC.mapfile(file)
-
- Return the mapping entry for the given *file*, which can be passed as either a
- filename or an :func:`FSSpec` result, and which need not exist.
-
- The mapping entry is returned as a tuple ``(version, type, creator, postcreator,
- flags, extension, appname, postappname, mimetype, entryname)``, where *version*
- is the entry version number, *type* is the 4-character filetype, *creator* is
- the 4-character creator type, *postcreator* is the 4-character creator code of
- an optional application to post-process the file after downloading, *flags* are
- various bits specifying whether to transfer in binary or ascii and such,
- *extension* is the filename extension for this file type, *appname* is the
- printable name of the application to which this file belongs, *postappname* is
- the name of the postprocessing application, *mimetype* is the MIME type of this
- file and *entryname* is the name of this entry.
-
-
-.. method:: IC.maptypecreator(type, creator[, filename])
-
- Return the mapping entry for files with given 4-character *type* and *creator*
- codes. The optional *filename* may be specified to further help finding the
- correct entry (if the creator code is ``'????'``, for instance).
-
- The mapping entry is returned in the same format as for *mapfile*.
-
-
-.. method:: IC.settypecreator(file)
-
- Given an existing *file*, specified either as a filename or as an :func:`FSSpec`
- result, set its creator and type correctly based on its extension. The finder
- is told about the change, so the finder icon will be updated quickly.
Modified: python/branches/py3k/Doc/library/index.rst
==============================================================================
--- python/branches/py3k/Doc/library/index.rst (original)
+++ python/branches/py3k/Doc/library/index.rst Tue May 13 00:25:16 2008
@@ -73,6 +73,4 @@
misc.rst
windows.rst
unix.rst
- mac.rst
- macosa.rst
undoc.rst
Deleted: python/branches/py3k/Doc/library/mac.rst
==============================================================================
--- python/branches/py3k/Doc/library/mac.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,23 +0,0 @@
-.. _mac-specific-services:
-
-*************************
-MacOS X specific services
-*************************
-
-This chapter describes modules that are only available on the Mac OS X platform.
-
-See the chapters :ref:`mac-scripting` and :ref:`undoc-mac-modules` for more
-modules, and the HOWTO :ref:`using-on-mac` for a general introduction to
-Mac-specific Python programming.
-
-
-.. toctree::
-
- ic.rst
- macos.rst
- macostools.rst
- easydialogs.rst
- framework.rst
- autogil.rst
- carbon.rst
- colorpicker.rst
Deleted: python/branches/py3k/Doc/library/macos.rst
==============================================================================
--- python/branches/py3k/Doc/library/macos.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,93 +0,0 @@
-
-:mod:`MacOS` --- Access to Mac OS interpreter features
-======================================================
-
-.. module:: MacOS
- :platform: Mac
- :synopsis: Access to Mac OS-specific interpreter features.
-
-
-This module provides access to MacOS specific functionality in the Python
-interpreter, such as how the interpreter eventloop functions and the like. Use
-with care.
-
-Note the capitalization of the module name; this is a historical artifact.
-
-
-.. data:: runtimemodel
-
- Always ``'macho'``.
-
-
-.. data:: linkmodel
-
- The way the interpreter has been linked. As extension modules may be
- incompatible between linking models, packages could use this information to give
- more decent error messages. The value is one of ``'static'`` for a statically
- linked Python, ``'framework'`` for Python in a Mac OS X framework, ``'shared'``
- for Python in a standard Unix shared library. Older Pythons could also have the
- value ``'cfm'`` for Mac OS 9-compatible Python.
-
-
-.. exception:: Error
-
- .. index:: module: macerrors
-
- This exception is raised on MacOS generated errors, either from functions in
- this module or from other mac-specific modules like the toolbox interfaces. The
- arguments are the integer error code (the :cdata:`OSErr` value) and a textual
- description of the error code. Symbolic names for all known error codes are
- defined in the standard module :mod:`macerrors`.
-
-
-.. function:: GetErrorString(errno)
-
- Return the textual description of MacOS error code *errno*.
-
-
-.. function:: DebugStr(message [, object])
-
- On Mac OS X the string is simply printed to stderr (on older Mac OS systems more
- elaborate functionality was available), but it provides a convenient location to
- attach a breakpoint in a low-level debugger like :program:`gdb`.
-
-
-.. function:: SysBeep()
-
- Ring the bell.
-
-
-.. function:: GetTicks()
-
- Get the number of clock ticks (1/60th of a second) since system boot.
-
-
-.. function:: GetCreatorAndType(file)
-
- Return the file creator and file type as two four-character strings. The *file*
- parameter can be a pathname or an ``FSSpec`` or ``FSRef`` object.
-
-
-.. function:: SetCreatorAndType(file, creator, type)
-
- Set the file creator and file type. The *file* parameter can be a pathname or an
- ``FSSpec`` or ``FSRef`` object. *creator* and *type* must be four character
- strings.
-
-
-.. function:: openrf(name [, mode])
-
- Open the resource fork of a file. Arguments are the same as for the built-in
- function :func:`open`. The object returned has file-like semantics, but it is
- not a Python file object, so there may be subtle differences.
-
-
-.. function:: WMAvailable()
-
- Checks whether the current process has access to the window manager. The method
- will return ``False`` if the window manager is not available, for instance when
- running on Mac OS X Server or when logged in via ssh, or when the current
- interpreter is not running from a fullblown application bundle. A script runs
- from an application bundle either when it has been started with
- :program:`pythonw` instead of :program:`python` or when running as an applet.
-
Deleted: python/branches/py3k/Doc/library/macosa.rst
==============================================================================
--- python/branches/py3k/Doc/library/macosa.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,92 +0,0 @@
-
-.. _mac-scripting:
-
-*********************
-MacPython OSA Modules
-*********************
-
-This chapter describes the current implementation of the Open Scripting
-Architecure (OSA, also commonly referred to as AppleScript) for Python, allowing
-you to control scriptable applications from your Python program, and with a
-fairly pythonic interface. Development on this set of modules has stopped, and a
-replacement is expected for Python 2.5.
-
-For a description of the various components of AppleScript and OSA, and to get
-an understanding of the architecture and terminology, you should read Apple's
-documentation. The "Applescript Language Guide" explains the conceptual model
-and the terminology, and documents the standard suite. The "Open Scripting
-Architecture" document explains how to use OSA from an application programmers
-point of view. In the Apple Help Viewer these books are located in the Developer
-Documentation, Core Technologies section.
-
-As an example of scripting an application, the following piece of AppleScript
-will get the name of the frontmost :program:`Finder` window and print it::
-
- tell application "Finder"
- get name of window 1
- end tell
-
-In Python, the following code fragment will do the same::
-
- import Finder
-
- f = Finder.Finder()
- print(f.get(f.window(1).name))
-
-As distributed the Python library includes packages that implement the standard
-suites, plus packages that interface to a small number of common applications.
-
-To send AppleEvents to an application you must first create the Python package
-interfacing to the terminology of the application (what :program:`Script Editor`
-calls the "Dictionary"). This can be done from within the :program:`PythonIDE`
-or by running the :file:`gensuitemodule.py` module as a standalone program from
-the command line.
-
-The generated output is a package with a number of modules, one for every suite
-used in the program plus an :mod:`__init__` module to glue it all together. The
-Python inheritance graph follows the AppleScript inheritance graph, so if a
-program's dictionary specifies that it includes support for the Standard Suite,
-but extends one or two verbs with extra arguments then the output suite will
-contain a module :mod:`Standard_Suite` that imports and re-exports everything
-from :mod:`StdSuites.Standard_Suite` but overrides the methods that have extra
-functionality. The output of :mod:`gensuitemodule` is pretty readable, and
-contains the documentation that was in the original AppleScript dictionary in
-Python docstrings, so reading it is a good source of documentation.
-
-The output package implements a main class with the same name as the package
-which contains all the AppleScript verbs as methods, with the direct object as
-the first argument and all optional parameters as keyword arguments. AppleScript
-classes are also implemented as Python classes, as are comparisons and all the
-other thingies.
-
-The main Python class implementing the verbs also allows access to the
-properties and elements declared in the AppleScript class "application". In the
-current release that is as far as the object orientation goes, so in the example
-above we need to use ``f.get(f.window(1).name)`` instead of the more Pythonic
-``f.window(1).name.get()``.
-
-If an AppleScript identifier is not a Python identifier the name is mangled
-according to a small number of rules:
-
-* spaces are replaced with underscores
-
-* other non-alphanumeric characters are replaced with ``_xx_`` where ``xx`` is
- the hexadecimal character value
-
-* any Python reserved word gets an underscore appended
-
-Python also has support for creating scriptable applications in Python, but The
-following modules are relevant to MacPython AppleScript support:
-
-.. toctree::
-
- gensuitemodule.rst
- aetools.rst
- aepack.rst
- aetypes.rst
- miniaeframe.rst
-
-
-In addition, support modules have been pre-generated for :mod:`Finder`,
-:mod:`Terminal`, :mod:`Explorer`, :mod:`Netscape`, :mod:`CodeWarrior`,
-:mod:`SystemEvents` and :mod:`StdSuites`.
Deleted: python/branches/py3k/Doc/library/macostools.rst
==============================================================================
--- python/branches/py3k/Doc/library/macostools.rst Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,115 +0,0 @@
-
-:mod:`macostools` --- Convenience routines for file manipulation
-================================================================
-
-.. module:: macostools
- :platform: Mac
- :synopsis: Convenience routines for file manipulation.
-
-
-This module contains some convenience routines for file-manipulation on the
-Macintosh. All file parameters can be specified as pathnames, :class:`FSRef` or
-:class:`FSSpec` objects. This module expects a filesystem which supports forked
-files, so it should not be used on UFS partitions.
-
-The :mod:`macostools` module defines the following functions:
-
-
-.. function:: copy(src, dst[, createpath[, copytimes]])
-
- Copy file *src* to *dst*. If *createpath* is non-zero the folders leading to
- *dst* are created if necessary. The method copies data and resource fork and
- some finder information (creator, type, flags) and optionally the creation,
- modification and backup times (default is to copy them). Custom icons, comments
- and icon position are not copied.
-
-
-.. function:: copytree(src, dst)
-
- Recursively copy a file tree from *src* to *dst*, creating folders as needed.
- *src* and *dst* should be specified as pathnames.
-
-
-.. function:: mkalias(src, dst)
-
- Create a finder alias *dst* pointing to *src*.
-
-
-.. function:: touched(dst)
-
- Tell the finder that some bits of finder-information such as creator or type for
- file *dst* has changed. The file can be specified by pathname or fsspec. This
- call should tell the finder to redraw the files icon.
-
- .. deprecated:: 2.6
- The function is a no-op on OS X.
-
-
-.. data:: BUFSIZ
-
- The buffer size for ``copy``, default 1 megabyte.
-
-Note that the process of creating finder aliases is not specified in the Apple
-documentation. Hence, aliases created with :func:`mkalias` could conceivably
-have incompatible behaviour in some cases.
-
-
-:mod:`findertools` --- The :program:`finder`'s Apple Events interface
-=====================================================================
-
-.. module:: findertools
- :platform: Mac
- :synopsis: Wrappers around the finder's Apple Events interface.
-
-
-.. index:: single: AppleEvents
-
-This module contains routines that give Python programs access to some
-functionality provided by the finder. They are implemented as wrappers around
-the AppleEvent interface to the finder.
-
-All file and folder parameters can be specified either as full pathnames, or as
-:class:`FSRef` or :class:`FSSpec` objects.
-
-The :mod:`findertools` module defines the following functions:
-
-
-.. function:: launch(file)
-
- Tell the finder to launch *file*. What launching means depends on the file:
- applications are started, folders are opened and documents are opened in the
- correct application.
-
-
-.. function:: Print(file)
-
- Tell the finder to print a file. The behaviour is identical to selecting the
- file and using the print command in the finder's file menu.
-
-
-.. function:: copy(file, destdir)
-
- Tell the finder to copy a file or folder *file* to folder *destdir*. The
- function returns an :class:`Alias` object pointing to the new file.
-
-
-.. function:: move(file, destdir)
-
- Tell the finder to move a file or folder *file* to folder *destdir*. The
- function returns an :class:`Alias` object pointing to the new file.
-
-
-.. function:: sleep()
-
- Tell the finder to put the Macintosh to sleep, if your machine supports it.
-
-
-.. function:: restart()
-
- Tell the finder to perform an orderly restart of the machine.
-
-
-.. function:: shutdown()
-
- Tell the finder to perform an orderly shutdown of the machine.
-
Modified: python/branches/py3k/Doc/library/plistlib.rst
==============================================================================
--- python/branches/py3k/Doc/library/plistlib.rst (original)
+++ python/branches/py3k/Doc/library/plistlib.rst Tue May 13 00:25:16 2008
@@ -65,19 +65,6 @@
Return *rootObject* as a plist-formatted string.
-
-.. function:: readPlistFromResource(path[, restype='plst'[, resid=0]])
-
- Read a plist from the resource with type *restype* from the resource fork of
- *path*. Availability: MacOS X.
-
-
-.. function:: writePlistToResource(rootObject, path[, restype='plst'[, resid=0]])
-
- Write *rootObject* as a resource with type *restype* to the resource fork of
- *path*. Availability: MacOS X.
-
-
The following class is available:
.. class:: Data(data)
Modified: python/branches/py3k/Doc/library/undoc.rst
==============================================================================
--- python/branches/py3k/Doc/library/undoc.rst (original)
+++ python/branches/py3k/Doc/library/undoc.rst Tue May 13 00:25:16 2008
@@ -37,104 +37,6 @@
:mod:`sunaudio`
--- Interpret Sun audio headers (may become obsolete or a tool/demo).
-
-.. _undoc-mac-modules:
-
-Undocumented Mac OS modules
-===========================
-
-
-:mod:`applesingle` --- AppleSingle decoder
-------------------------------------------
-
-.. module:: applesingle
- :platform: Mac
- :synopsis: Rudimentary decoder for AppleSingle format files.
-
-
-:mod:`icopen` --- Internet Config replacement for :meth:`open`
---------------------------------------------------------------
-
-.. module:: icopen
- :platform: Mac
- :synopsis: Internet Config replacement for open().
-
-
-Importing :mod:`icopen` will replace the builtin :meth:`open` with a version
-that uses Internet Config to set file type and creator for new files.
-
-
-:mod:`macerrors` --- Mac OS Errors
-----------------------------------
-
-.. module:: macerrors
- :platform: Mac
- :synopsis: Constant definitions for many Mac OS error codes.
-
-
-:mod:`macerrors` contains constant definitions for many Mac OS error codes.
-
-
-:mod:`macresource` --- Locate script resources
-----------------------------------------------
-
-.. module:: macresource
- :platform: Mac
- :synopsis: Locate script resources.
-
-
-:mod:`macresource` helps scripts finding their resources, such as dialogs and
-menus, without requiring special case code for when the script is run under
-MacPython, as a MacPython applet or under OSX Python.
-
-
-:mod:`Nav` --- NavServices calls
---------------------------------
-
-.. module:: Nav
- :platform: Mac
- :synopsis: Interface to Navigation Services.
-
-
-A low-level interface to Navigation Services.
-
-
-:mod:`PixMapWrapper` --- Wrapper for PixMap objects
----------------------------------------------------
-
-.. module:: PixMapWrapper
- :platform: Mac
- :synopsis: Wrapper for PixMap objects.
-
-
-:mod:`PixMapWrapper` wraps a PixMap object with a Python object that allows
-access to the fields by name. It also has methods to convert to and from
-:mod:`PIL` images.
-
-
-:mod:`videoreader` --- Read QuickTime movies
---------------------------------------------
-
-.. module:: videoreader
- :platform: Mac
- :synopsis: Read QuickTime movies frame by frame for further processing.
-
-
-:mod:`videoreader` reads and decodes QuickTime movies and passes a stream of
-images to your program. It also provides some support for audio tracks.
-
-
-:mod:`W` --- Widgets built on :mod:`FrameWork`
-----------------------------------------------
-
-.. module:: W
- :platform: Mac
- :synopsis: Widgets for the Mac, built on top of FrameWork.
-
-
-The :mod:`W` widgets are used extensively in the :program:`IDE`.
-
-
.. _obsolete-modules:
Obsolete
Modified: python/branches/py3k/Doc/using/mac.rst
==============================================================================
--- python/branches/py3k/Doc/using/mac.rst (original)
+++ python/branches/py3k/Doc/using/mac.rst Tue May 13 00:25:16 2008
@@ -12,9 +12,6 @@
any other Unix platform, but there are a number of additional features such as
the IDE and the Package Manager that are worth pointing out.
-The Mac-specific modules are documented in :ref:`mac-specific-services`.
-
-
.. _getting-osx:
Getting and Installing MacPython
Modified: python/branches/py3k/Lib/binhex.py
==============================================================================
--- python/branches/py3k/Lib/binhex.py (original)
+++ python/branches/py3k/Lib/binhex.py Tue May 13 00:25:16 2008
@@ -43,68 +43,39 @@
#
# This code is no longer byte-order dependent
-#
-# Workarounds for non-mac machines.
-try:
- from Carbon.File import FSSpec, FInfo
- from MacOS import openrf
-
- def getfileinfo(name):
- finfo = FSSpec(name).FSpGetFInfo()
- dir, file = os.path.split(name)
- # XXX Get resource/data sizes
- fp = io.open(name, 'rb')
- fp.seek(0, 2)
- dlen = fp.tell()
- fp = openrf(name, '*rb')
- fp.seek(0, 2)
- rlen = fp.tell()
- return file, finfo, dlen, rlen
-
- def openrsrc(name, *mode):
- if not mode:
- mode = '*rb'
- else:
- mode = '*' + mode[0]
- return openrf(name, mode)
-except ImportError:
- #
- # Glue code for non-macintosh usage
- #
-
- class FInfo:
- def __init__(self):
- self.Type = '????'
- self.Creator = '????'
- self.Flags = 0
-
- def getfileinfo(name):
- finfo = FInfo()
- fp = io.open(name, 'rb')
- # Quick check for textfile
- data = fp.read(512)
- if 0 not in data:
- finfo.Type = 'TEXT'
- fp.seek(0, 2)
- dsize = fp.tell()
- fp.close()
- dir, file = os.path.split(name)
- file = file.replace(':', '-', 1)
- return file, finfo, dsize, 0
-
- class openrsrc:
- def __init__(self, *args):
- pass
+class FInfo:
+ def __init__(self):
+ self.Type = '????'
+ self.Creator = '????'
+ self.Flags = 0
+
+def getfileinfo(name):
+ finfo = FInfo()
+ fp = io.open(name, 'rb')
+ # Quick check for textfile
+ data = fp.read(512)
+ if 0 not in data:
+ finfo.Type = 'TEXT'
+ fp.seek(0, 2)
+ dsize = fp.tell()
+ fp.close()
+ dir, file = os.path.split(name)
+ file = file.replace(':', '-', 1)
+ return file, finfo, dsize, 0
+
+class openrsrc:
+ def __init__(self, *args):
+ pass
- def read(self, *args):
- return b''
+ def read(self, *args):
+ return b''
- def write(self, *args):
- pass
+ def write(self, *args):
+ pass
- def close(self):
- pass
+ def close(self):
+ pass
class _Hqxcoderengine:
"""Write data to the coder in 3-byte chunks"""
Deleted: python/branches/py3k/Lib/plat-mac/Audio_mac.py
==============================================================================
--- python/branches/py3k/Lib/plat-mac/Audio_mac.py Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,121 +0,0 @@
-QSIZE = 100000
-error='Audio_mac.error'
-
-class Play_Audio_mac:
-
- def __init__(self, qsize=QSIZE):
- self._chan = None
- self._qsize = qsize
- self._outrate = 22254
- self._sampwidth = 1
- self._nchannels = 1
- self._gc = []
- self._usercallback = None
-
- def __del__(self):
- self.stop()
- self._usercallback = None
-
- def wait(self):
- import time
- while self.getfilled():
- time.sleep(0.1)
- self._chan = None
- self._gc = []
-
- def stop(self, quietNow = 1):
- ##chan = self._chan
- self._chan = None
- ##chan.SndDisposeChannel(1)
- self._gc = []
-
- def setoutrate(self, outrate):
- self._outrate = outrate
-
- def setsampwidth(self, sampwidth):
- self._sampwidth = sampwidth
-
- def setnchannels(self, nchannels):
- self._nchannels = nchannels
-
- def writeframes(self, data):
- import time
- from Carbon.Sound import bufferCmd, callBackCmd, extSH
- import struct
- import MacOS
- if not self._chan:
- from Carbon import Snd
- self._chan = Snd.SndNewChannel(5, 0, self._callback)
- nframes = len(data) / self._nchannels / self._sampwidth
- if len(data) != nframes * self._nchannels * self._sampwidth:
- raise error('data is not a whole number of frames')
- while self._gc and \
- self.getfilled() + nframes > \
- self._qsize / self._nchannels / self._sampwidth:
- time.sleep(0.1)
- if self._sampwidth == 1:
- import audioop
- data = audioop.add(data, '\x80'*len(data), 1)
- h1 = struct.pack('llHhllbbl',
- id(data)+MacOS.string_id_to_buffer,
- self._nchannels,
- self._outrate, 0,
- 0,
- 0,
- extSH,
- 60,
- nframes)
- h2 = 22*'\0'
- h3 = struct.pack('hhlll',
- self._sampwidth*8,
- 0,
- 0,
- 0,
- 0)
- header = h1+h2+h3
- self._gc.append((header, data))
- self._chan.SndDoCommand((bufferCmd, 0, header), 0)
- self._chan.SndDoCommand((callBackCmd, 0, 0), 0)
-
- def _callback(self, *args):
- del self._gc[0]
- if self._usercallback:
- self._usercallback()
-
- def setcallback(self, callback):
- self._usercallback = callback
-
- def getfilled(self):
- filled = 0
- for header, data in self._gc:
- filled = filled + len(data)
- return filled / self._nchannels / self._sampwidth
-
- def getfillable(self):
- return (self._qsize / self._nchannels / self._sampwidth) - self.getfilled()
-
- def ulaw2lin(self, data):
- import audioop
- return audioop.ulaw2lin(data, 2)
-
-def test():
- import aifc
- import EasyDialogs
- fn = EasyDialogs.AskFileForOpen(message="Select an AIFF soundfile", typeList=("AIFF",))
- if not fn: return
- af = aifc.open(fn, 'r')
- print(af.getparams())
- p = Play_Audio_mac()
- p.setoutrate(af.getframerate())
- p.setsampwidth(af.getsampwidth())
- p.setnchannels(af.getnchannels())
- BUFSIZ = 10000
- while 1:
- data = af.readframes(BUFSIZ)
- if not data: break
- p.writeframes(data)
- print('wrote', len(data), 'space', p.getfillable())
- p.wait()
-
-if __name__ == '__main__':
- test()
Deleted: python/branches/py3k/Lib/plat-mac/EasyDialogs.py
==============================================================================
--- python/branches/py3k/Lib/plat-mac/EasyDialogs.py Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,837 +0,0 @@
-"""Easy to use dialogs.
-
-Message(msg) -- display a message and an OK button.
-AskString(prompt, default) -- ask for a string, display OK and Cancel buttons.
-AskPassword(prompt, default) -- like AskString(), but shows text as bullets.
-AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons.
-GetArgv(optionlist, commandlist) -- fill a sys.argv-like list using a dialog
-AskFileForOpen(...) -- Ask the user for an existing file
-AskFileForSave(...) -- Ask the user for an output file
-AskFolder(...) -- Ask the user to select a folder
-bar = Progress(label, maxvalue) -- Display a progress bar
-bar.set(value) -- Set value
-bar.inc( *amount ) -- increment value by amount (default=1)
-bar.label( *newlabel ) -- get or set text label.
-
-More documentation in each function.
-This module uses DLOG resources 260 and on.
-Based upon STDWIN dialogs with the same names and functions.
-"""
-
-from Carbon.Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog
-from Carbon import Qd
-from Carbon import QuickDraw
-from Carbon import Dialogs
-from Carbon import Windows
-from Carbon import Dlg,Win,Evt,Events # sdm7g
-from Carbon import Ctl
-from Carbon import Controls
-from Carbon import Menu
-from Carbon import AE
-import Nav
-import MacOS
-from Carbon.ControlAccessor import * # Also import Controls constants
-import Carbon.File
-import macresource
-import os
-import sys
-
-__all__ = ['Message', 'AskString', 'AskPassword', 'AskYesNoCancel',
- 'GetArgv', 'AskFileForOpen', 'AskFileForSave', 'AskFolder',
- 'ProgressBar']
-
-_initialized = 0
-
-def _initialize():
- global _initialized
- if _initialized: return
- macresource.need("DLOG", 260, "dialogs.rsrc", __name__)
-
-def _interact():
- """Make sure the application is in the foreground"""
- AE.AEInteractWithUser(50000000)
-
-def cr2lf(text):
- if '\r' in text:
- text = '\n'.join(text.split('\r'))
- return text
-
-def lf2cr(text):
- if '\n' in text:
- text = '\r'.join(text.split('\n'))
- if len(text) > 253:
- text = text[:253] + '\311'
- return text
-
-def Message(msg, id=260, ok=None):
- """Display a MESSAGE string.
-
- Return when the user clicks the OK button or presses Return.
-
- The MESSAGE string can be at most 255 characters long.
- """
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
- return
- h = d.GetDialogItemAsControl(2)
- SetDialogItemText(h, lf2cr(msg))
- if ok is not None:
- h = d.GetDialogItemAsControl(1)
- h.SetControlTitle(ok)
- d.SetDialogDefaultItem(1)
- d.AutoSizeDialog()
- d.GetDialogWindow().ShowWindow()
- while 1:
- n = ModalDialog(None)
- if n == 1:
- return
-
-
-def AskString(prompt, default = "", id=261, ok=None, cancel=None):
- """Display a PROMPT string and a text entry field with a DEFAULT string.
-
- Return the contents of the text entry field when the user clicks the
- OK button or presses Return.
- Return None when the user clicks the Cancel button.
-
- If omitted, DEFAULT is empty.
-
- The PROMPT and DEFAULT strings, as well as the return value,
- can be at most 255 characters long.
- """
-
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
- return
- h = d.GetDialogItemAsControl(3)
- SetDialogItemText(h, lf2cr(prompt))
- h = d.GetDialogItemAsControl(4)
- SetDialogItemText(h, lf2cr(default))
- d.SelectDialogItemText(4, 0, 999)
-# d.SetDialogItem(4, 0, 255)
- if ok is not None:
- h = d.GetDialogItemAsControl(1)
- h.SetControlTitle(ok)
- if cancel is not None:
- h = d.GetDialogItemAsControl(2)
- h.SetControlTitle(cancel)
- d.SetDialogDefaultItem(1)
- d.SetDialogCancelItem(2)
- d.AutoSizeDialog()
- d.GetDialogWindow().ShowWindow()
- while 1:
- n = ModalDialog(None)
- if n == 1:
- h = d.GetDialogItemAsControl(4)
- return cr2lf(GetDialogItemText(h))
- if n == 2: return None
-
-def AskPassword(prompt, default='', id=264, ok=None, cancel=None):
- """Display a PROMPT string and a text entry field with a DEFAULT string.
- The string is displayed as bullets only.
-
- Return the contents of the text entry field when the user clicks the
- OK button or presses Return.
- Return None when the user clicks the Cancel button.
-
- If omitted, DEFAULT is empty.
-
- The PROMPT and DEFAULT strings, as well as the return value,
- can be at most 255 characters long.
- """
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
- return
- h = d.GetDialogItemAsControl(3)
- SetDialogItemText(h, lf2cr(prompt))
- pwd = d.GetDialogItemAsControl(4)
- bullets = '\245'*len(default)
-## SetControlData(pwd, kControlEditTextPart, kControlEditTextTextTag, bullets)
- SetControlData(pwd, kControlEditTextPart, kControlEditTextPasswordTag, default)
- d.SelectDialogItemText(4, 0, 999)
- Ctl.SetKeyboardFocus(d.GetDialogWindow(), pwd, kControlEditTextPart)
- if ok is not None:
- h = d.GetDialogItemAsControl(1)
- h.SetControlTitle(ok)
- if cancel is not None:
- h = d.GetDialogItemAsControl(2)
- h.SetControlTitle(cancel)
- d.SetDialogDefaultItem(Dialogs.ok)
- d.SetDialogCancelItem(Dialogs.cancel)
- d.AutoSizeDialog()
- d.GetDialogWindow().ShowWindow()
- while 1:
- n = ModalDialog(None)
- if n == 1:
- h = d.GetDialogItemAsControl(4)
- return cr2lf(GetControlData(pwd, kControlEditTextPart, kControlEditTextPasswordTag))
- if n == 2: return None
-
-def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262):
- """Display a QUESTION string which can be answered with Yes or No.
-
- Return 1 when the user clicks the Yes button.
- Return 0 when the user clicks the No button.
- Return -1 when the user clicks the Cancel button.
-
- When the user presses Return, the DEFAULT value is returned.
- If omitted, this is 0 (No).
-
- The QUESTION string can be at most 255 characters.
- """
-
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
- return
- # Button assignments:
- # 1 = default (invisible)
- # 2 = Yes
- # 3 = No
- # 4 = Cancel
- # The question string is item 5
- h = d.GetDialogItemAsControl(5)
- SetDialogItemText(h, lf2cr(question))
- if yes is not None:
- if yes == '':
- d.HideDialogItem(2)
- else:
- h = d.GetDialogItemAsControl(2)
- h.SetControlTitle(yes)
- if no is not None:
- if no == '':
- d.HideDialogItem(3)
- else:
- h = d.GetDialogItemAsControl(3)
- h.SetControlTitle(no)
- if cancel is not None:
- if cancel == '':
- d.HideDialogItem(4)
- else:
- h = d.GetDialogItemAsControl(4)
- h.SetControlTitle(cancel)
- d.SetDialogCancelItem(4)
- if default == 1:
- d.SetDialogDefaultItem(2)
- elif default == 0:
- d.SetDialogDefaultItem(3)
- elif default == -1:
- d.SetDialogDefaultItem(4)
- d.AutoSizeDialog()
- d.GetDialogWindow().ShowWindow()
- while 1:
- n = ModalDialog(None)
- if n == 1: return default
- if n == 2: return 1
- if n == 3: return 0
- if n == 4: return -1
-
-
-
-
-screenbounds = Qd.GetQDGlobalsScreenBits().bounds
-screenbounds = screenbounds[0]+4, screenbounds[1]+4, \
- screenbounds[2]-4, screenbounds[3]-4
-
-kControlProgressBarIndeterminateTag = 'inde' # from Controls.py
-
-
-class ProgressBar:
- def __init__(self, title="Working...", maxval=0, label="", id=263):
- self.w = None
- self.d = None
- _initialize()
- self.d = GetNewDialog(id, -1)
- self.w = self.d.GetDialogWindow()
- self.label(label)
- self.title(title)
- self.set(0, maxval)
- self.d.AutoSizeDialog()
- self.w.ShowWindow()
- self.d.DrawDialog()
-
- def __del__(self):
- if self.w:
- self.w.BringToFront()
- self.w.HideWindow()
- del self.w
- del self.d
-
- def title(self, newstr=""):
- """title(text) - Set title of progress window"""
- self.w.BringToFront()
- self.w.SetWTitle(newstr)
-
- def label(self, *newstr):
- """label(text) - Set text in progress box"""
- self.w.BringToFront()
- if newstr:
- self._label = lf2cr(newstr[0])
- text_h = self.d.GetDialogItemAsControl(2)
- SetDialogItemText(text_h, self._label)
-
- def _update(self, value):
- maxval = self.maxval
- if maxval == 0: # an indeterminate bar
- Ctl.IdleControls(self.w) # spin the barber pole
- else: # a determinate bar
- if maxval > 32767:
- value = int(value/(maxval/32767.0))
- maxval = 32767
- maxval = int(maxval)
- value = int(value)
- progbar = self.d.GetDialogItemAsControl(3)
- progbar.SetControlMaximum(maxval)
- progbar.SetControlValue(value) # set the bar length
-
- # Test for cancel button
- ready, ev = Evt.WaitNextEvent( Events.mDownMask, 1 )
- if ready :
- what,msg,when,where,mod = ev
- part = Win.FindWindow(where)[0]
- if Dlg.IsDialogEvent(ev):
- ds = Dlg.DialogSelect(ev)
- if ds[0] and ds[1] == self.d and ds[-1] == 1:
- self.w.HideWindow()
- self.w = None
- self.d = None
- raise KeyboardInterrupt(ev)
- else:
- if part == 4: # inDrag
- self.w.DragWindow(where, screenbounds)
- else:
- MacOS.HandleEvent(ev)
-
-
- def set(self, value, max=None):
- """set(value) - Set progress bar position"""
- if max is not None:
- self.maxval = max
- bar = self.d.GetDialogItemAsControl(3)
- if max <= 0: # indeterminate bar
- bar.SetControlData(0,kControlProgressBarIndeterminateTag,'\x01')
- else: # determinate bar
- bar.SetControlData(0,kControlProgressBarIndeterminateTag,'\x00')
- if value < 0:
- value = 0
- elif value > self.maxval:
- value = self.maxval
- self.curval = value
- self._update(value)
-
- def inc(self, n=1):
- """inc(amt) - Increment progress bar position"""
- self.set(self.curval + n)
-
-ARGV_ID=265
-ARGV_ITEM_OK=1
-ARGV_ITEM_CANCEL=2
-ARGV_OPTION_GROUP=3
-ARGV_OPTION_EXPLAIN=4
-ARGV_OPTION_VALUE=5
-ARGV_OPTION_ADD=6
-ARGV_COMMAND_GROUP=7
-ARGV_COMMAND_EXPLAIN=8
-ARGV_COMMAND_ADD=9
-ARGV_ADD_OLDFILE=10
-ARGV_ADD_NEWFILE=11
-ARGV_ADD_FOLDER=12
-ARGV_CMDLINE_GROUP=13
-ARGV_CMDLINE_DATA=14
-
-##def _myModalDialog(d):
-## while 1:
-## ready, ev = Evt.WaitNextEvent(0xffff, -1)
-## print 'DBG: WNE', ready, ev
-## if ready :
-## what,msg,when,where,mod = ev
-## part, window = Win.FindWindow(where)
-## if Dlg.IsDialogEvent(ev):
-## didit, dlgdone, itemdone = Dlg.DialogSelect(ev)
-## print 'DBG: DialogSelect', didit, dlgdone, itemdone, d
-## if didit and dlgdone == d:
-## return itemdone
-## elif window == d.GetDialogWindow():
-## d.GetDialogWindow().SelectWindow()
-## if part == 4: # inDrag
-## d.DragWindow(where, screenbounds)
-## else:
-## MacOS.HandleEvent(ev)
-## else:
-## MacOS.HandleEvent(ev)
-##
-def _setmenu(control, items):
- mhandle = control.GetControlData_Handle(Controls.kControlMenuPart,
- Controls.kControlPopupButtonMenuHandleTag)
- menu = Menu.as_Menu(mhandle)
- for item in items:
- if type(item) == type(()):
- label = item[0]
- else:
- label = item
- if label[-1] == '=' or label[-1] == ':':
- label = label[:-1]
- menu.AppendMenu(label)
-## mhandle, mid = menu.getpopupinfo()
-## control.SetControlData_Handle(Controls.kControlMenuPart,
-## Controls.kControlPopupButtonMenuHandleTag, mhandle)
- control.SetControlMinimum(1)
- control.SetControlMaximum(len(items)+1)
-
-def _selectoption(d, optionlist, idx):
- if idx < 0 or idx >= len(optionlist):
- MacOS.SysBeep()
- return
- option = optionlist[idx]
- if type(option) == type(()):
- if len(option) == 4:
- help = option[2]
- elif len(option) > 1:
- help = option[-1]
- else:
- help = ''
- else:
- help = ''
- h = d.GetDialogItemAsControl(ARGV_OPTION_EXPLAIN)
- if help and len(help) > 250:
- help = help[:250] + '...'
- Dlg.SetDialogItemText(h, help)
- hasvalue = 0
- if type(option) == type(()):
- label = option[0]
- else:
- label = option
- if label[-1] == '=' or label[-1] == ':':
- hasvalue = 1
- h = d.GetDialogItemAsControl(ARGV_OPTION_VALUE)
- Dlg.SetDialogItemText(h, '')
- if hasvalue:
- d.ShowDialogItem(ARGV_OPTION_VALUE)
- d.SelectDialogItemText(ARGV_OPTION_VALUE, 0, 0)
- else:
- d.HideDialogItem(ARGV_OPTION_VALUE)
-
-
-def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfolder=1, id=ARGV_ID):
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
- return
-# h = d.GetDialogItemAsControl(3)
-# SetDialogItemText(h, lf2cr(prompt))
-# h = d.GetDialogItemAsControl(4)
-# SetDialogItemText(h, lf2cr(default))
-# d.SelectDialogItemText(4, 0, 999)
-# d.SetDialogItem(4, 0, 255)
- if optionlist:
- _setmenu(d.GetDialogItemAsControl(ARGV_OPTION_GROUP), optionlist)
- _selectoption(d, optionlist, 0)
- else:
- d.GetDialogItemAsControl(ARGV_OPTION_GROUP).DeactivateControl()
- if commandlist:
- _setmenu(d.GetDialogItemAsControl(ARGV_COMMAND_GROUP), commandlist)
- if type(commandlist[0]) == type(()) and len(commandlist[0]) > 1:
- help = commandlist[0][-1]
- h = d.GetDialogItemAsControl(ARGV_COMMAND_EXPLAIN)
- Dlg.SetDialogItemText(h, help)
- else:
- d.GetDialogItemAsControl(ARGV_COMMAND_GROUP).DeactivateControl()
- if not addoldfile:
- d.GetDialogItemAsControl(ARGV_ADD_OLDFILE).DeactivateControl()
- if not addnewfile:
- d.GetDialogItemAsControl(ARGV_ADD_NEWFILE).DeactivateControl()
- if not addfolder:
- d.GetDialogItemAsControl(ARGV_ADD_FOLDER).DeactivateControl()
- d.SetDialogDefaultItem(ARGV_ITEM_OK)
- d.SetDialogCancelItem(ARGV_ITEM_CANCEL)
- d.GetDialogWindow().ShowWindow()
- d.DrawDialog()
- if hasattr(MacOS, 'SchedParams'):
- appsw = MacOS.SchedParams(1, 0)
- try:
- while 1:
- stringstoadd = []
- n = ModalDialog(None)
- if n == ARGV_ITEM_OK:
- break
- elif n == ARGV_ITEM_CANCEL:
- raise SystemExit
- elif n == ARGV_OPTION_GROUP:
- idx = d.GetDialogItemAsControl(ARGV_OPTION_GROUP).GetControlValue()-1
- _selectoption(d, optionlist, idx)
- elif n == ARGV_OPTION_VALUE:
- pass
- elif n == ARGV_OPTION_ADD:
- idx = d.GetDialogItemAsControl(ARGV_OPTION_GROUP).GetControlValue()-1
- if 0 <= idx < len(optionlist):
- option = optionlist[idx]
- if type(option) == type(()):
- option = option[0]
- if option[-1] == '=' or option[-1] == ':':
- option = option[:-1]
- h = d.GetDialogItemAsControl(ARGV_OPTION_VALUE)
- value = Dlg.GetDialogItemText(h)
- else:
- value = ''
- if len(option) == 1:
- stringtoadd = '-' + option
- else:
- stringtoadd = '--' + option
- stringstoadd = [stringtoadd]
- if value:
- stringstoadd.append(value)
- else:
- MacOS.SysBeep()
- elif n == ARGV_COMMAND_GROUP:
- idx = d.GetDialogItemAsControl(ARGV_COMMAND_GROUP).GetControlValue()-1
- if 0 <= idx < len(commandlist) and type(commandlist[idx]) == type(()) and \
- len(commandlist[idx]) > 1:
- help = commandlist[idx][-1]
- h = d.GetDialogItemAsControl(ARGV_COMMAND_EXPLAIN)
- Dlg.SetDialogItemText(h, help)
- elif n == ARGV_COMMAND_ADD:
- idx = d.GetDialogItemAsControl(ARGV_COMMAND_GROUP).GetControlValue()-1
- if 0 <= idx < len(commandlist):
- command = commandlist[idx]
- if type(command) == type(()):
- command = command[0]
- stringstoadd = [command]
- else:
- MacOS.SysBeep()
- elif n == ARGV_ADD_OLDFILE:
- pathname = AskFileForOpen()
- if pathname:
- stringstoadd = [pathname]
- elif n == ARGV_ADD_NEWFILE:
- pathname = AskFileForSave()
- if pathname:
- stringstoadd = [pathname]
- elif n == ARGV_ADD_FOLDER:
- pathname = AskFolder()
- if pathname:
- stringstoadd = [pathname]
- elif n == ARGV_CMDLINE_DATA:
- pass # Nothing to do
- else:
- raise RuntimeError("Unknown dialog item %d"%n)
-
- for stringtoadd in stringstoadd:
- if '"' in stringtoadd or "'" in stringtoadd or " " in stringtoadd:
- stringtoadd = repr(stringtoadd)
- h = d.GetDialogItemAsControl(ARGV_CMDLINE_DATA)
- oldstr = GetDialogItemText(h)
- if oldstr and oldstr[-1] != ' ':
- oldstr = oldstr + ' '
- oldstr = oldstr + stringtoadd
- if oldstr[-1] != ' ':
- oldstr = oldstr + ' '
- SetDialogItemText(h, oldstr)
- d.SelectDialogItemText(ARGV_CMDLINE_DATA, 0x7fff, 0x7fff)
- h = d.GetDialogItemAsControl(ARGV_CMDLINE_DATA)
- oldstr = GetDialogItemText(h)
- tmplist = oldstr.split()
- newlist = []
- while tmplist:
- item = tmplist[0]
- del tmplist[0]
- if item[0] == '"':
- while item[-1] != '"':
- if not tmplist:
- raise RuntimeError("Unterminated quoted argument")
- item = item + ' ' + tmplist[0]
- del tmplist[0]
- item = item[1:-1]
- if item[0] == "'":
- while item[-1] != "'":
- if not tmplist:
- raise RuntimeError("Unterminated quoted argument")
- item = item + ' ' + tmplist[0]
- del tmplist[0]
- item = item[1:-1]
- newlist.append(item)
- return newlist
- finally:
- if hasattr(MacOS, 'SchedParams'):
- MacOS.SchedParams(*appsw)
- del d
-
-def _process_Nav_args(dftflags, **args):
- import aepack
- import Carbon.AE
- import Carbon.File
- for k in args.keys():
- if args[k] is None:
- del args[k]
- # Set some defaults, and modify some arguments
- if 'dialogOptionFlags' not in args:
- args['dialogOptionFlags'] = dftflags
- if 'defaultLocation' in args and \
- not isinstance(args['defaultLocation'], Carbon.AE.AEDesc):
- defaultLocation = args['defaultLocation']
- if isinstance(defaultLocation, (Carbon.File.FSSpec, Carbon.File.FSRef)):
- args['defaultLocation'] = aepack.pack(defaultLocation)
- else:
- defaultLocation = Carbon.File.FSRef(defaultLocation)
- args['defaultLocation'] = aepack.pack(defaultLocation)
- if 'typeList' in args and not isinstance(args['typeList'], Carbon.Res.ResourceType):
- typeList = args['typeList'][:]
- # Workaround for OSX typeless files:
- if 'TEXT' in typeList and not '\0\0\0\0' in typeList:
- typeList = typeList + ('\0\0\0\0',)
- data = 'Pyth' + struct.pack("hh", 0, len(typeList))
- for type in typeList:
- data = data+type
- args['typeList'] = Carbon.Res.Handle(data)
- tpwanted = str
- if 'wanted' in args:
- tpwanted = args['wanted']
- del args['wanted']
- return args, tpwanted
-
-def _dummy_Nav_eventproc(msg, data):
- pass
-
-_default_Nav_eventproc = _dummy_Nav_eventproc
-
-def SetDefaultEventProc(proc):
- global _default_Nav_eventproc
- rv = _default_Nav_eventproc
- if proc is None:
- proc = _dummy_Nav_eventproc
- _default_Nav_eventproc = proc
- return rv
-
-def AskFileForOpen(
- message=None,
- typeList=None,
- # From here on the order is not documented
- version=None,
- defaultLocation=None,
- dialogOptionFlags=None,
- location=None,
- clientName=None,
- windowTitle=None,
- actionButtonLabel=None,
- cancelButtonLabel=None,
- preferenceKey=None,
- popupExtension=None,
- eventProc=_dummy_Nav_eventproc,
- previewProc=None,
- filterProc=None,
- wanted=None,
- multiple=None):
- """Display a dialog asking the user for a file to open.
-
- wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
- the other arguments can be looked up in Apple's Navigation Services documentation"""
-
- default_flags = 0x56 # Or 0xe4?
- args, tpwanted = _process_Nav_args(default_flags, version=version,
- defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
- location=location,clientName=clientName,windowTitle=windowTitle,
- actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
- message=message,preferenceKey=preferenceKey,
- popupExtension=popupExtension,eventProc=eventProc,previewProc=previewProc,
- filterProc=filterProc,typeList=typeList,wanted=wanted,multiple=multiple)
- _interact()
- try:
- rr = Nav.NavChooseFile(args)
- good = 1
- except Nav.error as arg:
- if arg.args[0] != -128: # userCancelledErr
- raise Nav.error(arg)
- return None
- if not rr.validRecord or not rr.selection:
- return None
- if issubclass(tpwanted, Carbon.File.FSRef):
- return tpwanted(rr.selection_fsr[0])
- if issubclass(tpwanted, Carbon.File.FSSpec):
- return tpwanted(rr.selection[0])
- if issubclass(tpwanted, str):
- return tpwanted(rr.selection_fsr[0].as_pathname())
- if issubclass(tpwanted, str):
- return tpwanted(rr.selection_fsr[0].as_pathname(), 'utf8')
- raise TypeError("Unknown value for argument 'wanted': %s" % repr(tpwanted))
-
-def AskFileForSave(
- message=None,
- savedFileName=None,
- # From here on the order is not documented
- version=None,
- defaultLocation=None,
- dialogOptionFlags=None,
- location=None,
- clientName=None,
- windowTitle=None,
- actionButtonLabel=None,
- cancelButtonLabel=None,
- preferenceKey=None,
- popupExtension=None,
- eventProc=_dummy_Nav_eventproc,
- fileType=None,
- fileCreator=None,
- wanted=None,
- multiple=None):
- """Display a dialog asking the user for a filename to save to.
-
- wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
- the other arguments can be looked up in Apple's Navigation Services documentation"""
-
-
- default_flags = 0x07
- args, tpwanted = _process_Nav_args(default_flags, version=version,
- defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
- location=location,clientName=clientName,windowTitle=windowTitle,
- actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
- savedFileName=savedFileName,message=message,preferenceKey=preferenceKey,
- popupExtension=popupExtension,eventProc=eventProc,fileType=fileType,
- fileCreator=fileCreator,wanted=wanted,multiple=multiple)
- _interact()
- try:
- rr = Nav.NavPutFile(args)
- good = 1
- except Nav.error as arg:
- if arg.args[0] != -128: # userCancelledErr
- raise Nav.error(arg)
- return None
- if not rr.validRecord or not rr.selection:
- return None
- if issubclass(tpwanted, Carbon.File.FSRef):
- raise TypeError("Cannot pass wanted=FSRef to AskFileForSave")
- if issubclass(tpwanted, Carbon.File.FSSpec):
- return tpwanted(rr.selection[0])
- if issubclass(tpwanted, str):
- if sys.platform == 'mac':
- fullpath = rr.selection[0].as_pathname()
- else:
- # This is gross, and probably incorrect too
- vrefnum, dirid, name = rr.selection[0].as_tuple()
- pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, ''))
- pardir_fsr = Carbon.File.FSRef(pardir_fss)
- pardir_path = pardir_fsr.FSRefMakePath() # This is utf-8
- name_utf8 = str(name, 'macroman').encode('utf8')
- fullpath = os.path.join(pardir_path, name_utf8)
- if issubclass(tpwanted, str):
- return str(fullpath, 'utf8')
- return tpwanted(fullpath)
- raise TypeError("Unknown value for argument 'wanted': %s" % repr(tpwanted))
-
-def AskFolder(
- message=None,
- # From here on the order is not documented
- version=None,
- defaultLocation=None,
- dialogOptionFlags=None,
- location=None,
- clientName=None,
- windowTitle=None,
- actionButtonLabel=None,
- cancelButtonLabel=None,
- preferenceKey=None,
- popupExtension=None,
- eventProc=_dummy_Nav_eventproc,
- filterProc=None,
- wanted=None,
- multiple=None):
- """Display a dialog asking the user for select a folder.
-
- wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
- the other arguments can be looked up in Apple's Navigation Services documentation"""
-
- default_flags = 0x17
- args, tpwanted = _process_Nav_args(default_flags, version=version,
- defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
- location=location,clientName=clientName,windowTitle=windowTitle,
- actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
- message=message,preferenceKey=preferenceKey,
- popupExtension=popupExtension,eventProc=eventProc,filterProc=filterProc,
- wanted=wanted,multiple=multiple)
- _interact()
- try:
- rr = Nav.NavChooseFolder(args)
- good = 1
- except Nav.error as arg:
- if arg.args[0] != -128: # userCancelledErr
- raise Nav.error(arg)
- return None
- if not rr.validRecord or not rr.selection:
- return None
- if issubclass(tpwanted, Carbon.File.FSRef):
- return tpwanted(rr.selection_fsr[0])
- if issubclass(tpwanted, Carbon.File.FSSpec):
- return tpwanted(rr.selection[0])
- if issubclass(tpwanted, str):
- return tpwanted(rr.selection_fsr[0].as_pathname())
- if issubclass(tpwanted, str):
- return tpwanted(rr.selection_fsr[0].as_pathname(), 'utf8')
- raise TypeError("Unknown value for argument 'wanted': %s" % repr(tpwanted))
-
-
-def test():
- import time
-
- Message("Testing EasyDialogs.")
- optionlist = (('v', 'Verbose'), ('verbose', 'Verbose as long option'),
- ('flags=', 'Valued option'), ('f:', 'Short valued option'))
- commandlist = (('start', 'Start something'), ('stop', 'Stop something'))
- argv = GetArgv(optionlist=optionlist, commandlist=commandlist, addoldfile=0)
- Message("Command line: %s"%' '.join(argv))
- for i in range(len(argv)):
- print('arg[%d] = %r' % (i, argv[i]))
- ok = AskYesNoCancel("Do you want to proceed?")
- ok = AskYesNoCancel("Do you want to identify?", yes="Identify", no="No")
- if ok > 0:
- s = AskString("Enter your first name", "Joe")
- s2 = AskPassword("Okay %s, tell us your nickname"%s, s, cancel="None")
- if not s2:
- Message("%s has no secret nickname"%s)
- else:
- Message("Hello everybody!!\nThe secret nickname of %s is %s!!!"%(s, s2))
- else:
- s = 'Anonymous'
- rv = AskFileForOpen(message="Gimme a file, %s"%s, wanted=Carbon.File.FSSpec)
- Message("rv: %s"%rv)
- rv = AskFileForSave(wanted=Carbon.File.FSRef, savedFileName="%s.txt"%s)
- Message("rv.as_pathname: %s"%rv.as_pathname())
- rv = AskFolder()
- Message("Folder name: %s"%rv)
- text = ( "Working Hard...", "Hardly Working..." ,
- "So far, so good!", "Keep on truckin'" )
- bar = ProgressBar("Progress, progress...", 0, label="Ramping up...")
- try:
- if hasattr(MacOS, 'SchedParams'):
- appsw = MacOS.SchedParams(1, 0)
- for i in range(20):
- bar.inc()
- time.sleep(0.05)
- bar.set(0,100)
- for i in range(100):
- bar.set(i)
- time.sleep(0.05)
- if i % 10 == 0:
- bar.label(text[(i/10) % 4])
- bar.label("Done.")
- time.sleep(1.0) # give'em a chance to see "Done."
- finally:
- del bar
- if hasattr(MacOS, 'SchedParams'):
- MacOS.SchedParams(*appsw)
-
-if __name__ == '__main__':
- try:
- test()
- except KeyboardInterrupt:
- Message("Operation Canceled.")
Deleted: python/branches/py3k/Lib/plat-mac/FrameWork.py
==============================================================================
--- python/branches/py3k/Lib/plat-mac/FrameWork.py Tue May 13 00:25:16 2008
+++ (empty file)
@@ -1,1123 +0,0 @@
-"A sort of application framework for the Mac"
-
-DEBUG=0
-
-import MacOS
-import traceback
-
-from Carbon.AE import *
-from Carbon.AppleEvents import *
-from Carbon.Ctl import *
-from Carbon.Controls import *
-from Carbon.Dlg import *
-from Carbon.Dialogs import *
-from Carbon.Evt import *
-from Carbon.Events import *
-from Carbon.Help import *
-from Carbon.Menu import *
-from Carbon.Menus import *
-from Carbon.Qd import *
-from Carbon.QuickDraw import *
-#from Carbon.Res import *
-#from Carbon.Resources import *
-#from Carbon.Snd import *
-#from Carbon.Sound import *
-from Carbon.Win import *
-from Carbon.Windows import *
-import types
-
-import EasyDialogs
-
-try:
- MyFrontWindow = FrontNonFloatingWindow
-except NameError:
- MyFrontWindow = FrontWindow
-
-kHighLevelEvent = 23 # Don't know what header file this should come from
-SCROLLBARWIDTH = 16 # Again, not a clue...
-
-# Trick to forestall a set of SIOUX menus being added to our menubar
-SIOUX_APPLEMENU_ID=32000
-
-
-# Map event 'what' field to strings
-eventname = {}
-eventname[1] = 'mouseDown'
-eventname[2] = 'mouseUp'
-eventname[3] = 'keyDown'
-eventname[4] = 'keyUp'
-eventname[5] = 'autoKey'
-eventname[6] = 'updateEvt'
-eventname[7] = 'diskEvt'
-eventname[8] = 'activateEvt'
-eventname[15] = 'osEvt'
-eventname[23] = 'kHighLevelEvent'
-
-# Map part codes returned by WhichWindow() to strings
-partname = {}
-partname[0] = 'inDesk'
-partname[1] = 'inMenuBar'
-partname[2] = 'inSysWindow'
-partname[3] = 'inContent'
-partname[4] = 'inDrag'
-partname[5] = 'inGrow'
-partname[6] = 'inGoAway'
-partname[7] = 'inZoomIn'
-partname[8] = 'inZoomOut'
-
-#
-# The useable portion of the screen
-# ## but what happens with multiple screens? jvr
-screenbounds = GetQDGlobalsScreenBits().bounds
-screenbounds = screenbounds[0]+4, screenbounds[1]+4, \
- screenbounds[2]-4, screenbounds[3]-4
-
-next_window_x = 16 # jvr
-next_window_y = 44 # jvr
-
-def windowbounds(width, height):
- "Return sensible window bounds"
- global next_window_x, next_window_y
- r, b = next_window_x+width, next_window_y+height
- if r > screenbounds[2]:
- next_window_x = 16
- if b > screenbounds[3]:
- next_window_y = 44
- l, t = next_window_x, next_window_y
- r, b = next_window_x+width, next_window_y+height
- next_window_x, next_window_y = next_window_x + 8, next_window_y + 20 # jvr
- return l, t, r, b
-
-_watch = None
-def setwatchcursor():
- global _watch
-
- if _watch is None:
- _watch = GetCursor(4).data
- SetCursor(_watch)
-
-def setarrowcursor():
- SetCursor(GetQDGlobalsArrow())
-
-class Application:
-
- "Application framework -- your application should be a derived class"
-
- def __init__(self, nomenubar=0):
- self._doing_asyncevents = 0
- self.quitting = 0
- self.needmenubarredraw = 0
- self._windows = {}
- self._helpmenu = None
- if nomenubar:
- self.menubar = None
- else:
- self.makemenubar()
-
- def __del__(self):
- if self._doing_asyncevents:
- self._doing_asyncevents = 0
- MacOS.SetEventHandler()
-
- def makemenubar(self):
- self.menubar = MenuBar(self)
- AppleMenu(self.menubar, self.getabouttext(), self.do_about)
- self.makeusermenus()
-
- def makeusermenus(self):
- self.filemenu = m = Menu(self.menubar, "File")
- self._quititem = MenuItem(m, "Quit", "Q", self._quit)
-
- def gethelpmenu(self):
- if self._helpmenu is None:
- self._helpmenu = HelpMenu(self.menubar)
- return self._helpmenu
-
- def _quit(self, *args):
- self.quitting = 1
-
- def cleanup(self):
- for w in self._windows.values():
- w.do_close()
- return self._windows == {}
-
- def appendwindow(self, wid, window):
- self._windows[wid] = window
-
- def removewindow(self, wid):
- del self._windows[wid]
-
- def getabouttext(self):
- return "About %s..." % self.__class__.__name__
-
- def do_about(self, id, item, window, event):
- EasyDialogs.Message("Hello, world!" + "\015(%s)" % self.__class__.__name__)
-
- # The main event loop is broken up in several simple steps.
- # This is done so you can override each individual part,
- # if you have a need to do extra processing independent of the
- # event type.
- # Normally, however, you'd just define handlers for individual
- # events.
-
- schedparams = (0, 0) # By default disable Python's event handling
- default_wait = None # By default we wait GetCaretTime in WaitNextEvent
-
- def mainloop(self, mask = everyEvent, wait = None):
- self.quitting = 0
- if hasattr(MacOS, 'SchedParams'):
- saveparams = MacOS.SchedParams(*self.schedparams)
- try:
- while not self.quitting:
- try:
- self.do1event(mask, wait)
- except (Application, SystemExit):
- # Note: the raising of "self" is old-fashioned idiom to
- # exit the mainloop. Calling _quit() is better for new
- # applications.
- break
- finally:
- if hasattr(MacOS, 'SchedParams'):
- MacOS.SchedParams(*saveparams)
-
- def dopendingevents(self, mask = everyEvent):
- """dopendingevents - Handle all pending events"""
- while self.do1event(mask, wait=0):
- pass
-
- def do1event(self, mask = everyEvent, wait = None):
- ok, event = self.getevent(mask, wait)
- if IsDialogEvent(event):
- if self.do_dialogevent(event):
- return
- if ok:
- self.dispatch(event)
- else:
- self.idle(event)
-
- def idle(self, event):
- pass
-
- def getevent(self, mask = everyEvent, wait = None):
- if self.needmenubarredraw:
- DrawMenuBar()
- self.needmenubarredraw = 0
- if wait is None:
- wait = self.default_wait
- if wait is None:
- wait = GetCaretTime()
- ok, event = WaitNextEvent(mask, wait)
- return ok, event
-
- def dispatch(self, event):
- # The following appears to be double work (already done in do1event)
- # but we need it for asynchronous event handling
- if IsDialogEvent(event):
- if self.do_dialogevent(event):
- return
- (what, message, when, where, modifiers) = event
- if what in eventname:
- name = "do_" + eventname[what]
- else:
- name = "do_%d" % what
- try:
- handler = getattr(self, name)
- except AttributeError:
- handler = self.do_unknownevent
- handler(event)
-
- def asyncevents(self, onoff):
- """asyncevents - Set asynchronous event handling on or off"""
- if MacOS.runtimemodel == 'macho':
- raise NotImplementedError('Unsupported in MachoPython')
- old = self._doing_asyncevents
- if old:
- MacOS.SetEventHandler()
- MacOS.SchedParams(*self.schedparams)
- if onoff:
- MacOS.SetEventHandler(self.dispatch)
- doint, dummymask, benice, howoften, bgyield = \
- self.schedparams
- MacOS.SchedParams(doint, everyEvent, benice,
- howoften, bgyield)
- self._doing_asyncevents = onoff
- return old
-
- def do_dialogevent(self, event):
- gotone, dlg, item = DialogSelect(event)
- if gotone:
- window = dlg.GetDialogWindow()
- if window in self._windows:
- self._windows[window].do_itemhit(item, event)
- else:
- print('Dialog event for unknown dialog')
- return 1
- return 0
-
- def do_mouseDown(self, event):
- (what, message, when, where, modifiers) = event
- partcode, wid = FindWindow(where)
-
- #
- # Find the correct name.
- #
- if partcode in partname:
- name = "do_" + partname[partcode]
- else:
- name = "do_%d" % partcode
-
- if wid is None:
- # No window, or a non-python window
- try:
- handler = getattr(self, name)
- except AttributeError:
- # Not menubar or something, so assume someone
- # else's window
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
- return
- elif wid in self._windows:
- # It is a window. Hand off to correct window.
- window = self._windows[wid]
- try:
- handler = getattr(window, name)
- except AttributeError:
- handler = self.do_unknownpartcode
- else:
- # It is a python-toolbox window, but not ours.
- handler = self.do_unknownwindow
- handler(partcode, wid, event)
-
- def do_inSysWindow(self, partcode, window, event):
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
-
- def do_inDesk(self, partcode, window, event):
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
-
- def do_inMenuBar(self, partcode, window, event):
- if not self.menubar:
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
- return
- (what, message, when, where, modifiers) = event
- result = MenuSelect(where)
- id = (result>>16) & 0xffff # Hi word
- if id >= 0x8000:
- id = -65536 + id
- item = result & 0xffff # Lo word
- self.do_rawmenu(id, item, window, event)
-
- def do_rawmenu(self, id, item, window, event):
- try:
- self.do_menu(id, item, window, event)
- finally:
- HiliteMenu(0)
-
- def do_menu(self, id, item, window, event):
- if hasattr(MacOS, 'OutputSeen'):
- MacOS.OutputSeen()
- self.menubar.dispatch(id, item, window, event)
-
-
- def do_unknownpartcode(self, partco