[review] Re: [PyKDE] KPDF KPart

Jim Bublitz jbublitz at nwinternet.com
Wed Sep 21 21:46:07 BST 2005


On Wednesday 21 September 2005 12:03, Rajeev J Sebastian wrote:
> 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 ;)

Actually, QMainWindow should work OK for most PyKDE apps, but probably not for 
KParts stuff.

Jim




More information about the PyQt mailing list