[PyKDE] KPDF KPart

David Boddie david at boddie.org.uk
Wed Sep 21 18:50:30 BST 2005


On Wed Sep 21 17:57:58, Rajeev J Sebastian wrote:

> I am trying to use the KPDF KPart in my application. So far, I have been
> successful in using KHTML Part, and so I want to go further. I am using the
> following code:
> 
> self.viewTB = createReadOnlyPart("libkpdfpart", self, "Kpdf",
>                                  "KParts::ReadOnlyPart")
> 
> However, this causes a segfault. Has anyone been successful in using the
> KPDF KPart in applications ? Could you offer some suggestions or tips on
> how to get this to work ?

In some ways it's surprising that a KHTML part works but a KPDF part doesn't.
However, I've never managed to successfully use a KGhostViewPart in this way,
so it's not a complete surprise.

Nonetheless, the following code works for me:


import sys
from kdecore import KApplication, KShortcut, KURL
from kdeui import KAction
from kfile import KFileDialog
from kparts import *

def openURL():

    url = KFileDialog.getOpenURL()
    part.openURL(url)

if __name__ == "__main__":

    app = KApplication(sys.argv, "")
    window = KParts.MainWindow()
    part = createReadOnlyPart("libkpdfpart", window, "KPDF",
                              "KParts::ReadOnlyPart")
    window.setCentralWidget(part.widget())
    #window.createGUI(part)
    action = KAction("&Open", KShortcut("Ctrl+O"), openURL,
                     window.actionCollection(), "openURL")
    window.show()
    
    sys.exit(app.exec_loop())


I'm using sip-snapshot-20050917 and PyQt-x11-gpl-snapshot-20050917 with
PyKDE-snapshot20050829, but I expect sip 4.3.1 and PyQt3.15 would work
with the same PyKDE snapshot.

David




More information about the PyQt mailing list