[PyQt] Troubles with QWebView

Kastner Mario kastnermario at gmail.com
Fri Nov 27 23:24:18 GMT 2009


I L.O.V.E PyQt4 ... really! But at this time i am realy at the end of my
knowledge.

I have following code:

SNIPPET START--------------------------------------------

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *


class PythonJS(QObject):
    
    @pyqtSignature("QString")
    def alert(self, msg):
        QMessageBox.information(None, "This is Python, and its great to
know!", msg)

    @pyqtSignature("", result="int")
    def fortune(self):
        return 23
        
if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)

    browser = QWebView()
    browser.show()


    frame = browser.page().mainFrame()

frame.setUrl(QUrl('http://localhost/clients/myconferences/username:testuser/password:testpass/'))
    frame.addToJavaScriptWindowObject("python", PythonJS())
    
    settings = QWebSettings.globalSettings()
    settings.setAttribute(QWebSettings.JavascriptEnabled, True)
    settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
    
    app.exec_()

SNIPPET END-----------------------------------------------

But i am not able to connect my PythonJS to my webpage! .... i turned
DeveloperExtras On to see what the js debugger says ... "
ReferenceError Can't find variable: python" ... when i do not call the
url with frame.setUrl() and put the html code static in with
browser.setHtml(...) everything works fine ... 


And i have another ticket *g* webkit ist quiet cool, css works find, but
not the -webkit-border-radius !? the corners are very very ugly
drawn ... i searched for a solutions but the only thing i found was that
i must set a border ... but i have so! ... background-color and border
are set ...


Thank you very much for your help and excuse my english skills ....

Mario



More information about the PyQt mailing list