2012-01-20 21 views
1

私は、giリポジトリを使用してPythonに埋め込むことで、pdfドキュメントを表示したいと考えています。私はEmbed evince Python GI

#!/usr/bin/env python 

from gi.repository import Gtk, Gio 
from gi.repository import EvinceDocument 
from gi.repository import EvinceView 

class HelloWorldApp(Gtk.Application): 
    def __init__(self): 
     Gtk.Application.__init__(self, application_id="apps.test.helloevince", flags=Gio.ApplicationFlags.FLAGS_NONE) 
     self.connect("activate", self.on_activate) 

    def on_activate(self, data=None): 
     window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) 
     window.set_title("Evince Gtk3 Python Example") 
     window.set_border_width(24) 
     scroll = Gtk.ScrolledWindow() 
     window.add(scroll) 
     EvinceDocument.init() 
     doc = EvinceDocument.Document.factory_get_document('file:///home/user/test.pdf') 
     view = EvinceView.View() 
     model = EvinceView.DocumentModel() 
     model.set_document(doc) 
     view.set_model(model) 
     scroll.add(view) 
     window.show_all() 
     self.add_window(window) 

if __name__ == "__main__": 
    app = HelloWorldApp() 
    app.run(None) 

あるコードhereに従うことをしようとしていますが、私はNO「factory_get_document」メソッドが存在しないことは明らかであるエラーに

Traceback (most recent call last): 
    File "./pdfViewer_pygi.py", line 19, in on_activate 
    doc = EvinceDocument.Document.factory_get_document('file:///home/user/test.pdf') 
AttributeError: type object 'Document' has no attribute 'factory_get_document' 

を取得します。代わりに何が...?どのようにして、pythonとgtk + 3を使ってpdf文書を埋め込むことができますか?

答えて

1

Evinceの新しいバージョンが必要です。

これはFedora 17(生皮)を使用して、3.3.3.1、最新示すに私のために働いている、そしてたぶん、あなたは、バインディングを取得するために示すをコンパイルすることができ

にFedora 16を用いて示す3.2.1で動作しませんワーキング。

+0

ありがとうございました。私はUbuntu 11.10にあります。これは3.2バージョンのバージョンです。ソースからコンパイルするのとは別のバージョン3.3を得るための簡単な方法はありません。 –

関連する問題