• Save
Using QtWebKit in PyQt as a N00b
Upcoming SlideShare
Loading in...5
×
 

Using QtWebKit in PyQt as a N00b

on

  • 12,697 views

 

Statistics

Views

Total Views
12,697
Views on SlideShare
12,549
Embed Views
148

Actions

Likes
4
Downloads
0
Comments
0

6 Embeds 148

http://tewson.com 86
http://www.slideshare.net 41
http://www.python.rk.edu.pl 11
http://www.techgig.com 8
http://74.125.153.132 1
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Using QtWebKit in PyQt as a N00b Using QtWebKit in PyQt as a N00b Presentation Transcript

  • Using QtWebKit in PyQt as a N00b @tewson BarcampBangkok 3, Sripathum University 1
  • WebKit ● Open Source Layout Engine ● Safari ● Google Chrome ● WebOS ● Epiphany ● Arora BarcampBangkok 3, Sripathum University 2
  • Qt ● Open Source Application Framework ● Google Earth ● VLC ● Skype BarcampBangkok 3, Sripathum University 3
  • QtWebKit lets you... ● Embed a Web browser in an application ● Interact between Document Object Model and other environment BarcampBangkok 3, Sripathum University 4
  • Dependencies sudo apt-get install python-qt4 with libqt4-core and libqt4-webkit? BarcampBangkok 3, Sripathum University 5
  • Let's Try... import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * app = QApplication(sys.argv) web = QWebView() web.load(QUrl(quot;http://barcampbangkok.orgquot;)) web.show() sys.exit(app.exec_()) BarcampBangkok 3, Sripathum University 6
  • Create Your Own Web Browser ● Use QtDesigner to Create UI ● Import UI to the Program ● Connect Signals and Slots: clicked(), urlChanged(), loadProgress(), etc. ● app.show()! BarcampBangkok 3, Sripathum University 7
  • Run JavaScript web = QwebView() frame = web.page().mainFrame() frame.evaluateJavaScript(quot;alert('Hello, World!');quot;) BarcampBangkok 3, Sripathum University 8
  • Cross the Border x = QObject() x.setObjectName(quot;xquot;) x.setProperty(quot;fooquot;,QVariant(quot;quot;)) x.setProperty(quot;barquot;,QVariant(quot;quot;)) frame.addToJavaScriptWindowObject(quot;xquot;,x) frame.evaluateJavaScript(quot;x.foo = 'foo'; x.bar = 5;quot;) print x.property(“foo”).toString() print x.property(“bar”).toInt() BarcampBangkok 3, Sripathum University 9
  • Injecting Firebug Lite * Use signals and slots to check first if the page has finished loading. * frame.evaluateJavaScript(quot;var firebug = document.createElement('script'); firebug.setAttribute('src','http://getfirebug.com/releases/lite/1.2/firebug-lite- compressed.js'); document.body.appendChild(firebug); (function() {if(window.firebug.version){firebug.init();} else {setTimeout(arguments.callee);}})(); void(firebug);quot;) Get this from Firebug Lite bookmarklet. http://getfirebug.com/lite.html BarcampBangkok 3, Sripathum University 10
  • Injecting jQuery It's the same idea as injecting Firebug Lite. BarcampBangkok 3, Sripathum University 11
  • Many More Interesting Examples at... http://labs.trolltech.com/blogs http://riverbankcomputing.com and Google, of course! BarcampBangkok 3, Sripathum University 12
  • Thanks @tewson tewson.com BarcampBangkok 3, Sripathum University 13