[PyKDE] "import khtml" causes weird problem

D Bera dbera.web at gmail.com
Thu Feb 9 01:44:33 GMT 2006


Hi
Have a look at this simple script below trying out kio.filepreview.

If I dont include "import khtml" at (1), slot_preview prints
<class 'kio.KFileItem'>
<kio.KFileItem object at 0xb74d3d2c>

If I include "import khtml" at (1), slot_preview prints
<type 'NotImplementedType'>
NotImplemented

(I found this in another app which uses khtml, so I really need that "import 
khtml" thing there. The problem exists even if I explicitly say "from khtml 
import ...").
--------------------------------------
#!/usr/bin/env python

import sys
from qt import *
from kdecore import *
from kio import *
from kdeui import *
import khtml    <----------------- (1)

def clicked ():
    urllist = QStringList ()
    urllist.append ("/home/debajyoti/LookNFeel/alien-night.jpg")
    job = KIO.filePreview (KURL.List (urllist), 128, 0, 0, 70, False, False)
    a.connect (job, SIGNAL ("gotPreview (const KFileItem *, const QPixmap 
&)"), slot_preview)
    a.connect (job, SIGNAL ("failed (const KFileItem *)"), slot_preview)

def slot_preview (kfileitem, preview=None):
    print type (kfileitem)
    print kfileitem

a = KApplication (sys.argv, "hello")
w = QWidget ()
button = QPushButton (w)
a.connect (button, SIGNAL ("clicked ()"), clicked)

a.setMainWidget(w)
a.setTopWidget(w)
w.resize(200,100)
w.move (100, 100)
w.show()
a.exec_loop()
--------------------------------------------

versions:
Qt: 3.3.4
KDE: 3.4.2
sip: 4.3.2
pyqt: 3.15.1
pykde: latest snapshot snapshot20060122
python: 2.4.1
anything else ?

If I move the import statement to after "a.connect (...)" then the first time, 
kfileitem gets the proper type, and becomes notimplemented henceforth. It 
happened with an earlier version of sip,pyqt and pykde - so this is something 
not suddenly new.
I dont have enough knowledge of sip et al, but looks like there is some 
problem with the module name getting stolen or lost when khtml is imported 
(!!!).
Is there any way, I can go around this problem ?

Thanks,
- dBera

-- 
--------------------------------------------------------
Debajyoti Bera @ http://dbera.blogspot.com
beagle / KDE fan
Mandriva / Inspiron-1100 user




More information about the PyQt mailing list