简体   繁体   中英

Simple “Hello-World” program for python-evince

I'm trying to write a simple "hello-world"-type program using the python-evince package for lucid-lynx gnome, that embeds Evince in a python-gtk window. The samples I've found on the web go like this:

import evince
import gtk

w = gtk.Window()
w.show()
e = evince.View()
w.add(e)
e.show()
document = evince.document_factory_get_document('my pdf file')
e.set_document(document)
gtk.main()

The problem is that "evince.set_document" no longer exists: The forums seem to indicate that there have been recent changes, but I have been unable to figure out the (probably very simple) modifications necessary to get this working. Can anyone help?

The API has changed, with an extra step added. These instructions should help:

>>> e = evince.View()
>>> docmodel = evince.DocumentModel()
>>> doc = evince.document_factory_get_document('file:///path/to/file/example.pdf')
>>> docmodel.set_document(doc)
>>> e.set_model(model)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM