Development/Languages/Python/PyKDE WebKit Tutorial/webkit7.py

Jump to: navigation, search
#!/usr/bin/env python                                                                   
 
import sys
 
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *  
 
from PyQt4.QtCore import *
from PyQt4.QtGui import * 
from PyQt4.QtWebKit import *
 
class Browser(object):
    def __init__(self):
        self.window = KMainWindow()
        self.widget = QWidget()    
        self.window.setCentralWidget(self.widget)
 
        layout = QVBoxLayout(self.widget)
 
        self.addressBar = QLineEdit(self.widget)
        layout.addWidget(self.addressBar)
 
        self.web = QWebView(self.widget)
        self.web.load(QUrl("http://kubuntu.org"))
        layout.addWidget(self.web)
        self.window.show()
 
        QObject.connect(self.addressBar, SIGNAL("returnPressed()"), self.loadUrl)
 
    def loadUrl(self):
        print "Loading " + self.addressBar.text()
        self.web.load( QUrl(self.addressBar.text()) )
 
appName = "python-kde-tutorial"
catalog = ""
programName = ki18n("PyKDE Tutorial")
version = "1.0"
description = ki18n("A Small Qt WebKit Example")
license = KAboutData.License_GPL
copyright = ki18n("(c) 2008 Canonical Ltd")
text = ki18n("none")
homePage = "www.kubuntu.org"
bugEmail = ""
 
aboutData = KAboutData (appName, catalog, programName, version, description,
license, copyright, text, homePage, bugEmail)
 
KCmdLineArgs.init(sys.argv, aboutData)
 
app = KApplication()
tutorial = Browser()
 
sys.exit(app.exec_())

This page was last modified on 29 June 2011, at 21:50. This page has been accessed 1,955 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal