PyQt4 and Webkit


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import sys
  2. from PyQt4.QtCore import *
  3. from PyQt4.QtGui import *
  4. from PyQt4.QtWebKit import *
  5. from PyQt4 import QtCore
  6.  
  7. def link_clicked(url) :
  8. print "click =" +url.toString()
  9.  
  10. def load_progress(load) :
  11. print "load =" + str(load)
  12.  
  13. app = QApplication(sys.argv)
  14. web = QWebView()
  15. web.load(QUrl("http://www.google.com"))
  16.  
  17. QtCore.QObject.connect(web, QtCore.SIGNAL("loadProgress (const QUrl&"), load_progress)
  18. QtCore.QObject.connect(web, QtCore.SIGNAL("urlChanged (int)"), link_clicked)
  19. QtCore.QObject.connect(web, QtCore.SIGNAL("linkClicked (const QUrl&)"), link_clicked)
  20.  
  21. web.show()
  22. sys.exit(app.exec_())

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.