Hello,
I have joined a file simpleHtmlPageColorViaJS.html which use a very simple 
script and jQuery : http://jqueryjs.googlecode.com/files/jquery-1.3.2.js .

I would like to do something similar via pyQt by adding some JS code to 
simpleHtmlPage.html.

I have used the following code jqueryFromPyqt.py without success. I don't see 
why. Any clue is welcome.

Christophe

============================================================================================
# -*- coding: utf-8 -*-
#!/usr/bin/env python

# Sources
#    http://www.mail-archive.com/[email protected]/msg17247.html
#    "jQuery" J. Chhaffer & K. Swedberg Ed. : PEARSON
    
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app = QApplication(sys.argv)
myWebKit = QWebView()
myWebKit.show()

myWebKit.setUrl(QUrl("simpleHtmlPage.html"))

myWebKit.page().mainFrame().evaluateJavaScript(open('jquery-1.3.2.js').read())

# There is  ROUGE  in the HTML source.
myWebKit.page().mainFrame().evaluateJavaScript("""$(document).ready(function(){$(".red").css("color",
 "#ff0000");});""")

sys.exit(app.exec_())

We want to have a RED WORD colored by jQuery.

A whole paragraph colored in red by jQuery.

# -*- coding: utf-8 -*-
#!/usr/bin/env python

# Sources
#    http://www.mail-archive.com/[email protected]/msg17247.html
#    "jQuery" J. Chhaffer & K. Swedberg Ed. : PEARSON
    
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app = QApplication(sys.argv)
myWebKit = QWebView()
myWebKit.show()

myWebKit.setUrl(QUrl("simpleHtmlPage.html"))

myWebKit.page().mainFrame().evaluateJavaScript(open('jquery-1.3.2.js').read())

# There is  <span class="rouge"><B>ROUGE</B>  in the HTML source.
myWebKit.page().mainFrame().evaluateJavaScript("""$(document).ready(function(){$(".red").css("color", "#ff0000");});""")

sys.exit(app.exec_())

We want to have a RED WORD colored by pyQt using jQuery.

A whole paragraph colored in red by pyQt using jQuery.

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to