[PyQt] Problem with signature to use JavaScript
projetmbc
projetmbc at club-internet.fr
Fri Apr 24 11:50:54 BST 2009
Hello, I'm trying to interact with JavaScript. I'm trying to modify the
code found here :
http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg13619.html .
My purpose is just to know on which picture the user has clicked.
Christophe who is drowning.... :-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: im_1.jpg
Type: image/jpeg
Size: 83794 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090424/8d7a6313/im_1-0001.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: im_2.jpg
Type: image/jpeg
Size: 105542 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090424/8d7a6313/im_2-0001.jpg
-------------- next part --------------
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# Source : http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg13619.html
# On importe les bibliothèques que nous allons utiliser.
import sys
from PyQt4 import QtCore, QtGui
from PyQt4 import QtWebKit
# On importe notre boîte de dialogue.
from WebView import Ui_dial_Projet2
class PythonJS(QtCore.QObject):
def __init__(self):
QtCore.QObject.__init__(self, QtGui.qApp)
self.setObjectName("versPyqt")
@QtCore.pyqtSignature("QString")
def alert(self, msg):
print "Message de vers Pyqt"
print msg
class dial_Projet2(QtGui.QDialog, Ui_dial_Projet2):
def __init__(self):
QtGui.QDialog.__init__(self)
Ui_dial_Projet2.__init__(self)
self.setupUi(self)
self.connect(self.bout_ok, QtCore.SIGNAL("clicked()"), self.change)
self.webView.setUrl(QtCore.QUrl("TestJavaScriptToPyQt.html"))
self.webView.page().mainFrame().addToJavaScriptWindowObject("versPyQt", PythonJS())
def change(self):
print 'clic'
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
testFichier = dial_Projet2()
testFichier.show()
sys.exit(app.exec_())
-------------- next part --------------
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:\Documents and Settings\Christophe\Mes documents\2,pyBaNaMa\Deb_PythonEtPyQT\CodesProjets\99-WebViev-JavaScript\JQueryTest.ui '
#
# Created: Fri Apr 24 11:04:06 2009
# by: PyQt4 UI code generator 4.4.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_dial_Projet2(object):
def setupUi(self, dial_Projet2):
dial_Projet2.setObjectName("dial_Projet2")
dial_Projet2.resize(805, 639)
dial_Projet2.setAutoFillBackground(True)
self.verticalLayout = QtGui.QVBoxLayout(dial_Projet2)
self.verticalLayout.setObjectName("verticalLayout")
self.bout_ok = QtGui.QPushButton(dial_Projet2)
self.bout_ok.setObjectName("bout_ok")
self.verticalLayout.addWidget(self.bout_ok)
self.webView = QtWebKit.QWebView(dial_Projet2)
self.webView.setUrl(QtCore.QUrl("about:blank"))
self.webView.setObjectName("webView")
self.verticalLayout.addWidget(self.webView)
self.retranslateUi(dial_Projet2)
QtCore.QMetaObject.connectSlotsByName(dial_Projet2)
def retranslateUi(self, dial_Projet2):
dial_Projet2.setWindowTitle(QtGui.QApplication.translate("dial_Projet2", "Projet n°2", None, QtGui.QApplication.UnicodeUTF8))
self.bout_ok.setText(QtGui.QApplication.translate("dial_Projet2", "PushButton", None, QtGui.QApplication.UnicodeUTF8))
from PyQt4 import QtWebKit
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
dial_Projet2 = QtGui.QDialog()
ui = Ui_dial_Projet2()
ui.setupUi(dial_Projet2)
dial_Projet2.show()
sys.exit(app.exec_())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090424/8d7a6313/TestJavaScriptToPyQt-0001.html
More information about the PyQt
mailing list