Examples

Python Bindings for KDE (PyKDE-3.16.0)
Prev |  | Next

# Templates and Example programs

## Templates

PyKDE includes a number of examples or "templates" that you can use as frameworks for building your own apps or experimenting with PyKDE. The templates are executable programs which usually construct an application with a main window, and in some cases with menus, toolbar and status bar, but have no other functionality. You can use these to get a quick start on creating a program, for exploring PyKDE, or for testing various ideas using PyKDE.

There are a number of template examples in the templates/ subdirectory. The same files a duplicated in templates/annotated/ and templates/basic/. The files in annotated/ have extensive comments, the files in basic/ have the comments stripped to make the templates easier to use in constructing your own programs.

The current set of templates provide basic applications using different UI construction strategies, an panel applet template, and a systray program template.

## Examples

Example programs are located in the examples/ directory (contributions are always welcome). All examples are run as "python <example name>.py", eg "python uisampler.py".

## uisampler.py

uisampler.py demonstrates a number of widgets and UI features of PyKDE.

For widgets, the panel on the right displays sample widgets. The widgets or other items for display are selected from the tree view on the left. A number of the examples are UI related items like TDEAction, KXMLGUI releated things, etc.These use either menudemo.py or xmlmenudemo.py to display examples of usage.

### menudemo.py

menudemo.py is a simple menu based example "application" that does nothing, but displays a UI (toolbar, status bar, menus) constructed using TDEAction and related classes. It runs as part of uisampler.py or will run stand-alone.

### xmlmenudemo.py

xmlmenudemo.py is a simple menu based example "application" that does nothing, but displays a UI (toolbar, status bar, menus) constructed using an XML 'desktop' file. It runs as part of uisampler.py or will run stand-alone.

## kurldemo.py

kurldemo.py displays the results of a number of KURL and KURL.List operations in a window. It's probably more instructive to look at the code for this example then to actually run it, but it is working code.

## mimetype.py

mimetype.py displays several tabs of KMimeType/KService/TDETrader related data

The output will vary with KDE version running or from machine to machine.

## pyTDEHTMLPart.py

pyTDEHTMLPart.py demonstrates importing TDEHTMLPart as a KPart.

The program is hard-coded to display the KDE website's main page, and requires an active internet connection to do the display (it will be blank if no internet connection is active).

The program is not designed as a complete browser example, and none of the links are "clickable" (it wouldn't be hard to extend it to do this however - see the TDEHTMLPart docs).

## systray.py

systray.py is a simple example of a system tray based application.

Prev | Home | Next
configure.py Options |  | DCOP and Extensions