Created
January 17, 2011 22:42
-
-
Save robotlolita/783635 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PySide.QtCore import * | |
from PySide.QtGui import * | |
from PySide.QtWebKit import * | |
class Everything(QObject): | |
@Slot(result=int) | |
def answer(self): | |
return 42 | |
app = QApplication(sys.argv) | |
web = QWebView() | |
web.load(QUrl("http://www.example.com/")) | |
web.show() | |
frame = web.page().mainFrame() | |
frame.addToJavaScriptWindowObject("Everything", Everything()) | |
frame.evaluateJavaScript("alert(Everything.answer())") # It alerts 0 instead of 42 | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment