[PyKDE] KPart crashs

Jim Bublitz jbublitz at nwinternet.com
Sun Sep 24 06:00:15 BST 2006


On Wednesday 19 April 2006 05:37, Daniel Marcel Eichler wrote:
> Hi
>
> I have KTabWidget in which i load a libkwordpart. Now, when i set the part
> to writeable, load a file and click with riht in the part-area, the whole
> app crashs. There is'nt any methods from me, which can cause the crash,
> and i do'nt understand the KCrash handler really. So, any hint?

I realize this is about 5 months after your original message. I was avoiding 
getting into this, because I thought there might some difficult problems 
PyKDE had with KParts, but it seems to work fine.

The following program imports a KPart - KPDF, KGhostview or KWord. Any of 
these work fine for me. KPDF and KGhostView will read and display a PDF file. 
KWord will open and allow you to edit a plain text file.

I'm not sure what was causing your crash, but these all work fine - I haven't 
made any modifications to PyKDE in this area (in fact I was just going to 
start digging into it, but apparently what I need is some good example 
programs). None of these have any of the menu interface stuff implemented.

I'm very sorry for the slow response (and in reading back, a pretty poor 
response on my part). I've had very little time to look at any of this the 
last few months.

Let me know if these don't work for you.

Jim

-----------------------------------------------------------

import sys

from qt import SIGNAL
from kdecore import KApplication, KCmdLineArgs, KAboutData
from kdeui import KMainWindow
from kfile import KFileDialog
import kparts

class MainWin (KMainWindow):
    def __init__ (self, *args):
        KMainWindow.__init__ (self)
        self.setGeometry (10, 10, 640, 480)

#        part = kparts.createReadOnlyPart ("libkpdfpart", self, "KPDF", 
#                              "KParts::ReadOnlyPart")

#        part = kparts.createReadOnlyPart ("libkghostviewpart", self, 
#                              "KGhostView", "KParts::ReadOnlyPart")
        
        part = kparts.createReadWritePart ("libkwordpart", self, "KWord",
                                "KParts::ReadWritePart")
        part.setReadWrite (True)    # comment this out for KPDF, KGhostView
        
        part.widget ().setGeometry (10, 10, 600, 400)
        part.openURL (KURL (KFileDialog.getOpenURL ()))

            

#-------------------- main ------------------------------------------------

description = "A basic application template"
version     = "1.0"
aboutData   = KAboutData ("", "",\
    version, description, KAboutData.License_GPL,\
    "(C) 2003 whoever the author is")

aboutData.addAuthor ("author1", "whatever they did", "email at somedomain")
aboutData.addAuthor ("author2", "they did something else", 
"another at email.address")

KCmdLineArgs.init (sys.argv, aboutData)

app = KApplication ()
mainWindow = MainWin (None, "main window")
mainWindow.show()
app.connect (app, SIGNAL ("lastWindowClosed ()"), app.quit)
app.exec_loop()




More information about the PyQt mailing list