|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
Running Python and the Interactive ShellThe ActivePython installer on Mac OS X installs symlinks for running
# If you use the Bash shell (the default on Mac OS 10.3 and up) place # the following in your Open the Terminal application
( ActivePython 2.4.5.14 (ActiveState Software Inc.) based on Python 2.4.5 (#1, Mar 30 2005, 09:33:37) [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> You can use the Python shell to interactively run Python code. This can be
very useful development and debugging tool. Learn how to use Python's built-in
>>> import os.path >>> dir(os.path) list of members of os.path module... >>> help(os.path) MAN page-like desciption of the os.path module... >>> help(os.path.join) help on the join function... Read the Python Tutorial for more information. pythonwOn Mac OS X, any process that provides a GUI (i.e. talks to the Aqua window manager) needs to be launched in a certain way. Thepythonw
command (just a stub that calls the actual Python executable as required) is
provided for this purpose. If your Python code provides a GUI, launch it with
pythonw instead of python. (There is a hack,
but it is not recommended.)
GUI ProgrammingTkinter is Python's binding to the cross-platform Tk GUI toolkit. ActivePython includes Tkinter by default, but on Mac OS X you must also install either ActiveTcl or TclTkAqua to use Tkinter. wxPython is another popular cross-platform GUI programming toolkit. It is available separately from http://www.wxpython.org/. The PyObjC project provides a bridge between Python and Apple's Objective-C system. Part of this system is the Cocao toolkit for Mac OS X GUI programming. See below for more information. Mac OS X-specific Libraries and ToolsDocumentationIn addition to the Python Library Reference that most Python developers will want to be familiar with, Python developers on Mac OS X may also want to take a look at the Macintosh Module Reference. Please be aware, however, that some of this documentation is out-of-date (some of referring to Mac OS 9, a.k.a. Mac Classic). The most useful sections will be MacOS Toolbox Modules and possibly MacPython OSA Modules, which discusses current bindings to Apple's OSA (Open Scripting Architecture, of which AppleScript is an implementation) system. PyObjCThe PyObjC project, as mentioned above, provides a bridge between Python and Apple's Objective-C system. In particular it provides the ability to write complete Mac OS X GUI applications in Python. PyObjC is, at the time of this writing, being very actively developed. There is currently no binary distribution of PyObjC for Python 2.4, however you can build and install the latest PyObjC into your ActivePython installation as follows:
py2app
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Install Location | /opt/ActivePython-2.4 by default, but can
be specified at install time |
|---|---|
| Local Documentation | Open
/opt/ActivePython-2.4/doc/python2.4/index.html
in your browser. |
The ActivePython installer on Linux, AIX and HP-UX installs to
/opt/ActivePython-2.4 by default, but an alternate
install directory (for example, somewhere in your home directory) can be
specified at install time. To be able to simply run python from
the shell you either need to add this install directory's bin dir
to your PATH:
# If you use the Bash shell place the following in # your~/.bashrcfile. PATH=/opt/ActivePython-2.4/bin:$PATH; export PATH # If you use thetcshshell place the following in # your~/.cshrcfile. setenv PATH /opt/ActivePython-2.4/bin:$PATH
or create symlinks from some directory alread on your PATH
(commonly /usr/local/bin) to python:
sudo ln -sf /opt/ActivePython-2.4/bin/python2.4 /usr/local/bin/python2.4 sudo ln -sf /usr/local/bin/python2.4 /usr/local/bin/python
Type python in the shell. (If you modified your shell startup
script, you may need to start a new shell to see the PATH changes.) You should
see something like the following:
ActivePython 2.4.5.14 (ActiveState Software Inc.) based on Python 2.4.5 (#1, Mar 30 2005, 09:33:37) [GCC 3.3.1 (SuSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
You can use the Python shell to interactively run Python code. This can be
very useful development and debugging tool. Learn how to use Python's built-in
dir() and
help()
introspection functions to dive into Python objects. For example, try running
the following:
>>> import os.path >>> dir(os.path) list of members of os.path module... >>> help(os.path) MAN page-like desciption of the os.path module... >>> help(os.path.join) help on the join function...
Read the Python Tutorial for more information.
Tkinter is Python's binding to the cross-platform Tk GUI toolkit and is a default part of any ActivePython installation on Linux, AIX and HP-UX.
wxPython is another popular cross-platform GUI programming toolkit. It is available separately from http://www.wxpython.org/.
As well there are the PyQT and PyGTK bindings to the QT and GTK GUI toolkits, respectively. They are both available separately.
| Install Location | /opt/ASpy$(pp.PyVerNotDot) by default, but can
be specified at install time |
|---|---|
| Local Documentation | Open
/opt/ASpy$(pp.PyVerNotDot)/doc/python2.4/index.html
in your browser. |
The ActivePython installer on Solaris installs to
/opt/ASpy$(pp.PyVerNotDot) by default, but an alternate
install directory (for example, somewhere in your home directory) can be
specified at install time. To be able to simply run python from
the shell you either need to add this install directory's bin dir
to your PATH:
# If you use the Bash shell place the following in # your~/.bashrcfile. PATH=/opt/ASpy$(pp.PyVerNotDot)/bin:$PATH; export PATH # If you use thetcshshell place the following in # your~/.cshrcfile. setenv PATH /opt/ASpy$(pp.PyVerNotDot)/bin:$PATH
or create symlinks from some directory alread on your PATH
(commonly /usr/local/bin) to python:
sudo ln -sf /opt/ASpy$(pp.PyVerNotDot)/bin/python2.4 /usr/local/bin/python2.4 sudo ln -sf /usr/local/bin/python2.4 /usr/local/bin/python
Type python in the shell. (If you modified your shell startup
script, you may need to start a new shell to see the PATH changes.) You should
see something like the following:
ActivePython 2.4.5.14 (ActiveState Software Inc.) based on Python 2.4.5 (#2, Mar 30 2005, 09:33:37) [C] on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>>
You can use the Python shell to interactively run Python code. This can be
very useful development and debugging tool. Learn how to use Python's built-in
dir() and
help()
introspection functions to dive into Python objects. For example, try running
the following:
>>> import os.path >>> dir(os.path) list of members of os.path module... >>> help(os.path) MAN page-like desciption of the os.path module... >>> help(os.path.join) help on the join function...
Read the Python Tutorial for more information.
|
|