wiki:PyXPCOM_OLD

## page was renamed from PyXPCOM See also pyxpcom (we should merge these two).

XPCOM is an acronym for "Cross Platform COM". It has come out of the Mozilla project, which maintains the main XPCOM project pages. The Python XPCOM package is a set of Python bindings to XPCOM, allowing a Python programmer to both use and implement XPCOM interfaces.

http://public.activestate.com/pyxpcom/

PyXPCOM is single process, meaning that you cannot use PyXPCOM to control a mozilla that is outside of your process space (as you can using ActiveX on IE). This means for us to make a python-mozilla application, we need to either:

  1. Tie GtkMozEmbed, PyGTK and PyXPCOM together.

We tried this way, it is difficult because both libraries try to intialise XPCOM, which takes a main thread handle and doesn't like bieng initialised twice, we made PyXPCOM not initialise it and only had GtkMozEmbed initialise it (because it is the one that creates the browser instance), but then we ran to wierd threading errors, there is a bugzilla issue against this: https://bugzilla.mozilla.org/show_bug.cgi?id=211315

We decided in the end to leave this avenue

  1. Tie MFCEmbed, PyGTK and PyXPCOM together.

In this method, we would simply pass the window handle to MFCEmbed, I started down this route and got distracted. Maybe I'll come back to it later. It may have the same duality problems as the above method.

  1. Use XULRunner.

XULRunner seems to basically designed to handle this problem, I wish I would have looked at it earlier. One of the problems with the two above embedding techniques (even if the threading issues are solved), is that they require us to implement all the window creation functions and history listeners, and to implement nsIXULWindow etc.

XULRunner has the advantage that it provides platform specific functions for creating file dialogs and windows etc. In my mind this is what we need. I'm just starting to compile XULRunner as I type. Heres' what I've done so far.

  1. I found this web site: http://wiki.mozilla.org/XUL:Xul_Runner#How_do_I_build_it.3F
  1. Basically do this:
export CVSROOT=:pserver:[email protected]:/cvsroot
echo -z3 >> $HOME/.cvsrc
cvs checkout mozilla/client.mk
cd mozilla
echo export MOZILLA_OFFICIAL=1 > .mozconfig
echo mk_add_options MOZILLA_OFFICIAL=1 >> .mozconfig
echo ac_add_options --enable-application=xulrunner >> .mozconfig
# For linux...
echo ac_add_options --enable-default-toolkit=gtk2 >> .mozconfig
echo ac_add_options --enable-xft >> .mozconfig
echo ac_add_options --disable-freetype2 >> .mozconfig
# For everyone
make -f client.mk checkout MOZ_CO_PROJECT=xulrunner
gmake -f client.mk build

How to make your own

These instructions come from Shane Hathaway http://aspn.activestate.com/ASPN/Mail/Message/pyxpcom/2484016

You'll need to have the mozilla include files somewhere in your include path

  1. Get the mozilla pyxpcom cvs code
  1. cvs -d :pserver:[email protected]:/cvsroot login
  2. type 'anoncvs'
  3. cvs -d :pserver:[email protected]:/cvsroot co -d pyxpcom mozilla/extensions/python/xpcom
  4. cd pyxpcom
  1. Download the attached files to the directory (Remove the .ksh extensions when saving)
  1. Build it

patch -p0 < HEAD.patch

python setup.py build

sudo python setup.py install

make

sudo make install

Install the Sample Component

  1. cp
Last modified 10 years ago Last modified on 2009-05-22T06:11:39+09:00

Attachments (3)

Download all attachments as: .zip