I almost always write my presentation slides using HTML. Usually I use Firefox to present them; it's the browser I normally run, so I know it's installd and the slides all work there. But there are several disadvantages to using Firefox:
- In fullscreen mode, it has a small "minimized urlbar" at the top of the screen that I've never figured out to banish -- not only is it visible to users, but it also messes up the geometry of the slides (they have to be 762 pixels high rather than 768);
- It's very heavyweight, bad when using a mini laptop or netbook;
- Any personal browsing preferences, like no-animation, flashblock or noscript, apply to slides too unless explicitly disabled, which I've forgotten to do more than once before a talk.
Last year, when I was researching lightweight browsers, one of the ones that impressed me most was something I didn't expect: the demo app that comes with pywebkitgtk (package python-webkit on Ubuntu). In just a few lines of Python, you can create your own browser with any UI you like, with a fully functional content area. Their current demo even has tabs.
So why not use pywebkitgtk to create a simple fullscreen webkit-based presentation tool?
It was even simpler than I expected. Here's the code:
#!/usr/bin/env python # python-gtk-webkit presentation program. # Copyright (C) 2009 by Akkana Peck. # Share and enjoy under the GPL v2 or later. import sys import gobject import gtk import webkit class WebBrowser(gtk.Window): def __init__(self, url): gtk.Window.__init__(self) self.fullscreen() self._browser= webkit.WebView() self.add(self._browser) self.connect('destroy', gtk.main_quit) self._browser.open(url) self.show_all() if __name__ == "__main__": if len(sys.argv) <= 1 : print "Usage:", sys.argv, "url" sys.exit(0) gobject.threads_init() webbrowser = WebBrowser(sys.argv) gtk.main()
Webkit and image buffering
It works great. The only problem is that webkit's image loading turns out to be fairly poor compared to Firefox's. In a presentation where most slides are full-page images, webkit clears the browser screen to white, then loads the image, creating a noticable flash each time. Having the images in cache, by stepping through the slide show then starting from the beginning again, doesn't help much (these are local images on disk anyway, not loaded from the net). Firefox loads the same images with no flash and no perceptible delay.
There might be some clever way to hack double-buffering in the app code. Perhaps something like catching the 'load-started' signal, switching to another gtk widget that's a static copy of the current page (if there's a way to do that), then switching back on 'load-finished'.
But that will be a separate article if I figure it out. Ideas welcome!
Update, years later: I've used this for quite a few real presentations now. Of course, I keep tweaking it: see my scripts page for the latest version.
[ 17:12 Nov 11, 2009 More programming | permalink to this entry | comments ]