Marcell Mars a écrit :
the simplest example of loading jquery.js (geti it from
http://jqueryjs.googlecode.com/files/jquery-1.3.2.js and put it in the
same directory with the snippet below) after loading html and then
using jquery syntax to change the background color into red:

run it in python interactive shell or better in ipython:

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

myWebKit = QWebView()
myWebKit.show()

myWebKit.setUrl(QUrl("http://www.google.com";))

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

myWebKit.page().mainFrame().evaluateJavaScript("""$(document).ready(function()
{ $("body").css("background", "#f00");});""")
Your example doesn't work for me. I've done the program given with tis message and the files which are ine the same folder. What's wrong ?

Christophe.

A simple test....

# -*- coding: utf-8 -*-
#!/usr/bin/env python
# Les lignes ci-dessus sont très importantes :
#    1°) La 1ère ligne indique le codage du fichier Python.
#    2°) La 2nde ligne est indispensable pour un bon fonctionnement sous Linux.

# PRESENTATION : ce script montre comment créé un fichier au format HTML ou 
PDF.
# AUTEUR : BAL Christophe
# MAIL : projet...@club.fr
# SITE : http://christophe_bal.club.fr/index.php
# DATE DE CREATION : 24/06/2008
# DERNIERE MODIFICATION : 10/12/2008
# 
# TEST(S) EFFECTUE(S) : programme testé sous Windows XP avec succès.

# 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 JQueryTest import Ui_dial_Projet2


class dial_Projet2(QtGui.QDialog, Ui_dial_Projet2):
    def __init__(self):
        QtGui.QDialog.__init__(self)
        Ui_dial_Projet2.__init__(self)

        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.webView = QtWebKit.QWebView(self)
        self.webView.setUrl(QtCore.QUrl("test.html"))
        self.webView.setObjectName("webView")
        self.verticalLayout.addWidget(self.webView)

        
self.webView.page().mainFrame().evaluateJavaScript(open('jquery.js').read())
        
self.webView.page().mainFrame().evaluateJavaScript("""$(document).ready(function()
        { $("body").css("background", "#ff0");});""")
        




if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    testFichier = dial_Projet2()
    testFichier.show()
    sys.exit(app.exec_())



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to