pythonwebkit-gtk, pythonwebkit-dfb

Luke Kenneth Casson Leighton luke.leighton at gmail.com
Mon May 16 19:32:12 EDT 2011


in preparation for a 0.8 release of pyjamas, a bit of work has been
done on pythonwebkit (http://www.gnu.org/software/pythonwebkit) that
makes it easier to compile and install.

pythonwebkit provides full and complete (see caveats below!) bindings
to web browser functionality... in python.  what you would normally
expect to be able to do in javascript "in-browser", you can do EXACTLY
the same thing, in a "declarative" programming style, in python:

import gtk
import pywebkitgtk

url = "http://www.gnu.org/software/pythonwebkit"
wv = pywebkitgtk.WebView(1024,768, url=url)

def _doc_loaded(*args):
    doc = wv.GetDomDocument()
    txt = doc.createTextNode("hello")
    doc.body.appendChild(txt)

wv.SetDocumentLoadedCallback(_doc_loaded)
gtk.main()

yes, that's really python, doing a createTextNode and an appendChild,
*not* javascript.  not interpreted javascript, not interpreted python,
*real* python, byte-coded and everything.  throw in some AJAX, some
browser event callbacks (onclick etc.) and some web browser timer
callbacks and it all starts to get a bit weird, as two or maybe three
disparate programming worlds that should never really have been
brought together suddenly.. um... well, are brought together.

the bit that's easier about installing pythonwebkit is that it is no
longer necessary to download and patch up the
http://code.google.com/p/pywebkitgtk project in order to use
pythonwebkit.  you can simply do "./autogen.sh" followed by the usual
"make" and "make install".  a new and absolute minimalist python
module is created and installed which will get you a blank window -
just like if you were firing up a python-GTK application or a
python-QT4 application.

anyway - just a bit of an informal not-really-announcement because,
well, it's a side-dependency to the pyjamas project, even if it is a
whopping 20mb one.  those caveats btw are that a) you can't set CSS
properties as if they were python object properties: you have to use
the method "setProperty", duh, and b) there are *no* 2D or 3D SVG
Canvas objects or functions available, yet, because it would take a
good full-time 7 to 10 days to smack the codegenerator into shape and
i'm waiting for someone to step forward and fund that work.  am still
servicing £20,000 in debt and still have to find a way to pay back a
complete stranger who incredibly kindly paid £4,000 in owed rent so
that we did not end up with a County Court Judgement against us.
myself, my partner and our 25 month old daughter still got evicted,
but that's another story.

against this kind of background, perhaps i might be forgiven for not
doing "freebie" free software development, i trust.

l.



More information about the Python-list mailing list