[PyQt] Troubles with QWebView
Phil Thompson
phil at riverbankcomputing.com
Sat Nov 28 10:38:09 GMT 2009
On Sat, 28 Nov 2009 00:24:18 +0100, Kastner Mario <kastnermario at gmail.com>
wrote:
> 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 ...
The first thing to try is to keep a reference to your PythonJS object - I'm
guessing it is getting garbage collected.
Phil
More information about the PyQt
mailing list