< PyKDE Programming

The Structure of a KDE Application

A basic KApplication

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

#!/usr/bin/python
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
 
sys.exit(app.exec_())

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.

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.