Static member functions are implemented as Python class functions. For example the C++ static member function TQObject::connect() is called from Python as TQObject.connect() or self.connect() if called from a sub-class of TQObject.
Throughout the bindings, the None value can be specified wherever NULL is acceptable to the underlying C++ code.
Equally, NULL is converted to None whenever it is returned by the underlying C++ code
Enumerated types are implemented as a set of simple variables corresponding to the separate enumerated values.
When using an enumerated value the name of the class (or a sub-class) in which the enumerated type was defined in must be included. For example:
TQt.SolidPattern TQWidget.TabFocus TQFrame.TabFocus |
The C++ code in KDE makes extensive use of namespaces (especially in the kio, kjs, tdehtml, tdefile, and tdeparts modules). In PyKDE, namespaces are treated as a "superclass". For example, "from tdeparts import KParts" will import the KParts namespace and all its members. To reference a class in the namespace, use <namespace name>..<classname>, for example, KParts.ReadOnlyPart. It isn't necessary to import the <classname> (ReadOnlyPart in the example).
Some return types or argument types may be different than those in the C++ KDE libs. This is done for convenience (eg returning/taking Python lists or dicts), because arguments are scalar (non-object) types passed by reference (eg int*, bool&), or because there is no way to express the C++ type in Python (eg template types)
Please check the Class Reference Docs which list all classes and methods in Python format.
PyKDE provides methods for determining both the KDE version being run and the PyKDE version being run. The version methods are:
return type | KDE | Example | PyKDE | Example | |
---|---|---|---|---|---|
int | KDE.versionMajor () | 3 | PyKDE.versionMajor () | 3 | |
int | KDE.versionMinor () | 1 | PyKDE.versionMinor () | 8 | |
int | KDE.versionRelease () | 4 | PyKDE.versionRelease () | 0 | |
string | KDE.versionString () | "3.1.4" | PyKDE.versionString () | "3.11.0" |
C++ allows the use of abstract classes. Abstract classes cannot be used in programs (instantiated) directly; their only purpose is to serve as a base class from which programmers can derive other classes that can be used.
An abstract class in C++ is defined as a class that has one or more 'pure virtual' methods. These can be identified in the C++ header files or C++ docs as methods set equal to 0, for example:
virtual int somePureVirtualMethod (int a) = 0; |
To derive a useful class from the abstract class, the programmer has to write methods to overload each of the pure virtual methods. Following a suggestion on the mailing list, the docs attempt to flag all abstract classes and identify the pure virtual methods which must be overloaded in the derived class. Derived classes can be created in Python by writing Python methods to overload the pure virtual methods - no C++ code is required.