[PyKDE] KPDF KPart
Rajeev J Sebastian
rajeev_jsv at dinamis.com
Wed Sep 21 20:03:57 BST 2005
On Wednesday 21 September 2005 6:32 pm, Jim Bublitz wrote:
> On Wednesday 21 September 2005 10:50, David Boddie wrote:
> > 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.
>
> It's important to use KParts.MainWindow instead of KMainWindow for your
> application - something that's easy to overlook (at least it is for me).
Im using neither ... I'm using a QMainWindow !!!
I wonder when my luck's going to run out ;)
Regards,
Rajeev J Sebastian
More information about the PyQt
mailing list