PyKDE Programming

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

This book will introduce its readers to the KDE functions that can be accessed through the pyKDE package and how to create QT based user interfaces within the KDE environment. The reading requires a basic understanding of programming in python.

Contents


[edit] Introduction

[edit] Requirements

This book requires a basic understanding of Python and Linux. In order to follow the material taught the following programs and libraries should be installed:

  • Python
  • PyKDE
  • PyQT

[edit] How to read this

This book is organized in three major parts

  • Building KDE Applications
  • Creating QT based GUI's
  • Bringing the two concepts together

[edit] KDE

[edit] The Structure of a KDE Application

[edit] A basic KApplication

Every KDE application you are going to write from now on will contain at least the following code.

#!/usr/bin/python
import sys
from kdecore import KApplication, KCmdLineArgs, KAboutData

aboutData   = KAboutData ("Kde Application",\
                "simlpe test",\
                "0.1",\
                "A basic KDE Application",\
                KAboutData.License_GPL,\
                "(C) 2004 Wiki User")

aboutData.addAuthor ("Dennis Schaaf", "Programmer & Author",  "email@somedomain")

KCmdLineArgs.init (sys.argv, aboutData)

app = KApplication ()
app.exec_loop()

Go ahead, run this file. The program will load and will not end until you terminate it.

[edit] QT

[edit] The structure of a QT Application

[edit] A basic QT Application

#!python
import sys
from qt import *
class HelloWindow(QMainWindow):
     def __init__ (self, *args):
          apply(QMainWindow.__init__, (self,) + args)

app=QApplication(sys.argv)
win=HelloWindow()
win.show()
app.connect(app, SIGNAL("lastWindowClosed()"),
app, SLOT("quit()"))
app.exec_loop()

[edit] QT & KDE

[edit] The structure of a QT based KDE Application

[edit] A basic PyKDE program

[edit] KDE Extras

[edit] DCOP

[edit] QT Extras

[edit] Shaped Windows

[edit] External References and Weblinks

[edit] KDE

[edit] Qt