Languages/Python/PyKDE WebKit Tutorial/webkit4.py: Difference between revisions

    From KDE TechBase
    m (Use new style classes)
    m (Text replace - "<code python>" to "<syntaxhighlight lang="python">")
    Line 1: Line 1:
    <code python>
    <syntaxhighlight lang="python">
    #!/usr/bin/env python                     
    #!/usr/bin/env python                     



    Revision as of 20:34, 29 June 2011

    <syntaxhighlight lang="python">

    1. !/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 Tutorial(object):

       def __init__(self):
           self.widget = QWidget()
    
           layout = QVBoxLayout(self.widget)
    
           self.web = QWebView(self.widget)
           self.web.load(QUrl("http://kubuntu.org"))
           layout.addWidget(self.web)
           self.widget.show()
    

    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 = Tutorial()

    sys.exit(app.exec_())