From AbiWiki

Jump to: navigation, search



PyAbiWord is a set of wrappers around AbiWidget that enable python programmers to use AbiWord in their PyGtk applications.

Getting the Source Code from SVN

This set of code is available from the AbiWord cvs server with module name "pyabiword".

For version 2.8 (the current stable version of AbiWord) do:

  svn co pyabiword

You get the current development version with:

  svn co pyabiword

Building pyabiword

To build it, you must first build libabiword as described in AbiWordSDK. Make sure to build libabiword with the "--enable-dynamic" configure option.

After that make sure that the


environment variable is set so that abiword-2.8.pc or abiword-2.9.pc is discoverable.

After that configure pyabiword with:

  ./configure --prefix=/Path/To/Install

and "make" it.

The appropriate packages will be placed in:




depending on your version of python. Then make sure your


environment variable is set so that /Path/To/Install/lib/python2.4/site-packages or Path/To/Install/lib/python2.5/site-packages is discoverable.

To use the AbiWidget from within python call the "Canvas()" method on the abiword object. This returns the AbiWidget object which can be used like any other PyGtk GtkWidget in addition to its own methods.

Like the C version of AbiWidget, by default, PyAbiWord starts in "OLPC" mode, which is "Normal View", with a small left border, zoom set to page widget and selections are made on per word granularity.

You can turn this behaviour off with the:





You can find a complete listing of all the methods available to the python AbiWidget at PyAbiWordMethods.

The Python wrapper supports all the [[[AbiWordSignals|AbiWordSignals]] signals] emitted by AbiWidget.


In addition to AbiWidget, PyAbiWord also wraps a useful little widget TableCreator. This widget allows users to interactively insert a table of specified size by dragging a mouse.

Follow the link to TableCreator to learn how to use this.

Example Code

A very simple program -


import sys
import pygtk
import gtk
import abiword

window = gtk.Window()
window.set_default_size(640, 480)
window.connect('delete-event', gtk.main_quit)

box = gtk.VBox()

abi = abiword.Canvas()

b = gtk.Button('render page')

i = gtk.Image()

def _clicked_cb(widget, abi, i):
    i.props.pixbuf = abi.render_page_to_image(1)

b.connect('clicked', lambda widget: _clicked_cb(widget, abi, i))


Personal tools