[Pythonmac-SIG] How to call Apple Help from Python via Carbon.AH wrapper

Kevin Walzer sw at wordtech-software.com
Mon Jun 27 06:24:26 CEST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi everyone,

A few weeks ago I asked about how to call Apple Help from a Python
application because that functionality is provided via Carbon.
Apparently this API is so crufty that no one quite knew how. :-)

After some trial and error, I figured it out, and am actually using it
in several non-Python applications via "python -c" calls, for which
direct access to the Carbon Help API would be difficult or impossible.
(Aquamacs is one of them, my Tk applications are also examples.)

Here's a Pythonic sample of initalizing/registering the help book:

from Carbon import AH
path = /Applications/MyApp.app
AH.AHRegisterHelpBook(path)

And here's a sample of how to load a help book from the help menu:

from Carbon import AH
AH.AHGotoPage('MyApp Help', None, None)

The 'MyApp Help' is the Apple Title tag that you would add to the main
help page, as per the Apple documentation on user help.

You'd also, of course, need to correctly set up the proper elements in
the info.plist file (CFBundleHelpBookFolder--the directory within the
Resources folder in the app bundle--and CFBundleHelpBookName, which is
the Apple Title tag).

For me the appeal of this approach is that it's built-in to OS X via the
system Python installation; I don't have to ask anyone to install an
external framework (or bundle it myself).

Hope this is useful to somebody.

- --
Cheers,

Kevin Walzer, PhD
WordTech Software--Open Source Applications and Packages for OS X
http://www.wordtech-software.com
http://www.kevin-walzer.com
http://www.smallbizmac.com.
mailto:sw at wordtech-software.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCv395JmdQs+6YVcoRAsCOAJ4luboCq7+weyhiVmTRuNkR03d6mwCggEUO
SnlouNefrLI+rVnhZqOAvbA=
=5SuN
-----END PGP SIGNATURE-----


More information about the Pythonmac-SIG mailing list