Moikka! Here's Adrián. I work for Igalia.

Embedding widgets from other processes with PyGTK

After discovering the Surf minimalistic web browser, I was just curious on how difficutl would it be to use the XEmbed protocol to wrap it into another application. It is far easier than I thought initially by using the gtk.Socket class which does implement the protocol in a convenient way, for example using the following Python code:

import gtk, sys

socket = gtk.Socket()
window = gtk.Window()
window.set_title(u"Embedded widget")

# Embed *after* inserting the socket in a window!

Save this in a file (e.g. and now you can run Surf the following way:

# Running surf with -e will print the X window ID
surf -e -u &
python <window-id>

(Thanks go to Claudio for pointing out the gtk.Socket/gtk.Plug classes)