Hi

I'm facing a strange bug with QTextBrowser, making it near of unusable for me 
with PyQt4.
I need to display some HTML with images embedded. To do that, I've to create a 
new QTextBrowser-heriting class, and implement loadResource.
I did so, and it works, but only for local pictures.

Here is my smallest test code :
#!/usr/bin/python

import sys, httplib, os.path
from PyQt4 import QtGui, QtCore

class myTextBrowser(QtGui.QTextBrowser):
    def loadResource (self, type, name):
        return QtGui.QPixmap("test.jpg")

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    a = myTextBrowser()
    a.document().setHtml("""Coucou :<br /><img src="test.jpg"/>""")
    a.show()
    sys.exit(app.exec_())


This code just work as expected, it only display one "TypeError: invalid 
result type from myTextBrowser.loadResource()" on the console.
Now, if I replace src="test.jpg" with src="http://somewhere/test.jpg"; or any 
other http:// URL, it'll fail, displaying 10 times the message "TypeError: 
invalid result type from myTextBrowser.loadResource()"
I tried the same code using C++, and it just worked.
So I fear it's a PyQt issue :/
I tried the PyQt4 snapshot two days ago, and it didn't work neither.

Do you have any idea to solve this ?

I also got a segfault with PyQt4 snapshot when I tried to use 
QDesktopServices, but it was perhaps my fault.


Thanks
        Pierre


P.S : my PyQt4 is coming from kubuntu edgy packages. It's pyqt4 4.0.1, with 
Qt4.2.

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to