Development/Tutorials/Plasma/Python/Using DataEngines

< Development‎ | Tutorials‎ | Plasma
Revision as of 14:34, 18 January 2009 by Sedwards (Talk | contribs)

Jump to: navigation, search

Contents

Abstract

One of the most important concepts in Plasma is that of the "DataEngine". DataEngines are used to deliver data from somewhere, often from an internet service for example, to your applet. In this tutorial we'll discuss DataEngines, what they are, and how to use them from your Plasma applet.

What are DataEngines?

As already mentioned, DataEngines are objects which serve to deliver some kind of data to Plasma applets. Plasma supports many different DataEngines out of the box which deliver all sorts of varied information about the state of the machine, e.g. CPU usage, memory usage, position of the mouse pointer; to things such as the current weather report, current time or the latest comic from the internet. DataEngines are used to supply the raw data which an applet can display. Separating the part of the code which fetches data from the part which displays the data means that one DataEngine can be reused by many applets, regardless of which language the DataEngine is written in. It also makes it easy for people to display the same data using different applets which may tuned to different tasks of screen form factors.

Exploring DataEngines

Plasma comes with a handy tool called plasmaengineexplorer to list the running DataEngines and examine them to see what kind of data and fields them send. plasmaengineexplorer can be simply started from the shell as so. plasmaengineexplorer Select the "time" in the pulldown list and then click on "Request". This will fetch the list of data sources which the "time" DataEngine makes available.

Dataengine snapshot.png

The "time" DataEngine periodically publishes the current time for many different timezones. The first timezone in the list ("/etc/localtime") is special and simply refers to the current local time on the computer without referring to a specific timezone. If you open the "/etc/localtime" node in the tree you can see which data fields the "time" DataEngine provides. The most important fields are the "Time" and "Date". The plasmaengineexplorer also lists what kind of data type the field is, e.g. a QString, QTime or QDate. This information is needed when hooking up a DataEngine to your applet.

Explore some of the other DataEngines in the list. Perhaps it will give yousome ideas for applets.

Connecting to a DataEngine

TODO: finish tutorial.


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal