PyKDE Programming/KDE Extras
A mimimal example of an application using the Kate KPart (Katepart):
import sys from PyKDE4.kdecore import KLibLoader from PyKDE4.kparts import KParts from PyQt4.QtGui import QApplication app = QApplication(sys.argv) factory = KLibLoader.self().factory("katepart") part = factory.create(None, "PartOfKate") w = part.widget() w.resize(500,300) w.show() sys.exit(app.exec_())
The script does the following:
- After importing everything needed, it creates a QApplication (Note that no KApplication is needed for using a KPart).
- A factory is created from the library “katepart”. A factory is a class which generates objects from a library.
- The factory is used to create an instance, a Katepart-object with no parent and the name “PartOfKate”. You can use any name here.
- The widget of the Katepart is resized (It looks better) and shown.
- The main loop of the Application is started.