PyKDE Programming/KDE

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The Structure of a KDE Application[edit]

A basic KApplication[edit]

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

import sys
from PyKDE4.kdecore import ki18n, KCmdLineArgs, KAboutData
from PyKDE4.kdeui   import KApplication

appName     = "kde-application"
catalog     = "simple test"
programName = ki18n("KDE Application")
version     = "1.0"

aboutData = KAboutData(appName, catalog, programName, version)
KCmdLineArgs.init (sys.argv, aboutData)
app = KApplication ()
# your main widget (the application window) would be created and shown here

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

Next we will learn how to add a first widget.