|
|
|
<HTML>
|
|
|
|
<HEAD>
|
|
|
|
<TITLE>Types and Related Topics</TITLE>
|
|
|
|
</HEAD>
|
|
|
|
<BODY CLASS="SECT1">
|
|
|
|
<DIV CLASS="NAVHEADER">
|
|
|
|
<TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0">
|
|
|
|
<TR>
|
|
|
|
<TH COLSPAN="3" ALIGN="center">Python Bindings for KDE (PyKDE-3.16.0)</TH>
|
|
|
|
</TR>
|
|
|
|
<TR>
|
|
|
|
<TD WIDTH="10%" ALIGN="left" VALIGN="bottom">
|
|
|
|
<A HREF="signal.html" ACCESSKEY="P">Prev</A>
|
|
|
|
</TD>
|
|
|
|
<TD WIDTH="80%" ALIGN="center" VALIGN="bottom"></TD>
|
|
|
|
<TD WIDTH="10%" ALIGN="right" VALIGN="bottom">
|
|
|
|
<A HREF="classref/index.html" ACCESSKEY="N">Next</A>
|
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
</TABLE>
|
|
|
|
<HR ALIGN="LEFT" WIDTH="100%">
|
|
|
|
</DIV>
|
|
|
|
<H1>Types and Related Topics</H1>
|
|
|
|
<H2>Static Member Functions</H2>
|
|
|
|
<P>
|
|
|
|
Static member functions are implemented as Python class functions.
|
|
|
|
For example the C++ static member function
|
|
|
|
<TT CLASS="LITERAL" >TQObject::connect()</TT>
|
|
|
|
is called from Python as
|
|
|
|
<TT CLASS="LITERAL">TQObject.connect()</TT> or
|
|
|
|
<TT CLASS="LITERAL">self.connect()</TT>
|
|
|
|
if called from a sub-class of
|
|
|
|
<TT CLASS="LITERAL">TQObject</TT>.
|
|
|
|
</P>
|
|
|
|
<h2>None and NULL</h2>
|
|
|
|
<P>Throughout the bindings, the
|
|
|
|
<TT CLASS="LITERAL">None</TT>
|
|
|
|
value can be specified wherever
|
|
|
|
<TT CLASS="LITERAL">NULL</TT>
|
|
|
|
is acceptable to the underlying C++ code.</P>
|
|
|
|
<P >Equally,
|
|
|
|
<TT CLASS="LITERAL">NULL</TT>
|
|
|
|
is converted to
|
|
|
|
<TT CLASS="LITERAL">None</TT>
|
|
|
|
whenever it is returned by the underlying C++ code
|
|
|
|
</P>
|
|
|
|
|
|
|
|
<h2>Enumerated Types</H2>
|
|
|
|
<P>
|
|
|
|
Enumerated types are implemented as a set of simple variables corresponding to
|
|
|
|
the separate enumerated values.
|
|
|
|
</P>
|
|
|
|
<P>
|
|
|
|
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:
|
|
|
|
</P>
|
|
|
|
<TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" >
|
|
|
|
<TR>
|
|
|
|
<TD>
|
|
|
|
<PRE CLASS="PROGRAMLISTING">
|
|
|
|
TQt.SolidPattern
|
|
|
|
TQWidget.TabFocus
|
|
|
|
TQFrame.TabFocus
|
|
|
|
</PRE>
|
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
</TABLE>
|
|
|
|
|
|
|
|
<H2>Namespaces</H2>
|
|
|
|
<P>
|
|
|
|
The C++ code in KDE makes extensive use of namespaces (especially in the tdeio, 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).
|
|
|
|
</P>
|
|
|
|
<h2>Return and Argument Types</h2>
|
|
|
|
<p>
|
|
|
|
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)
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Please check the <a href="docs.html">Class Reference Docs</a> which list all classes
|
|
|
|
and methods in Python format.
|
|
|
|
</p>
|
|
|
|
<h2>Version Information</h2><h4><i>New in PyKDE-3.11</i></h4>
|
|
|
|
<p>
|
|
|
|
PyKDE provides methods for determining both the KDE version being run and the PyKDE
|
|
|
|
version being run. The version methods are:
|
|
|
|
</p>
|
|
|
|
<table border="0" bgcolor="#E0E0E0" width="100%">
|
|
|
|
<tr>
|
|
|
|
<th align = "left" width = "20%"><u>return type</u></th>
|
|
|
|
<th align = "left" width = "20%"><u>KDE</u></th>
|
|
|
|
<th align = "center" width = "10%"><u>Example</u></th>
|
|
|
|
<th></th>
|
|
|
|
<th align = "left" width = "20%"><u>PyKDE</u></th>
|
|
|
|
<th align = "center" width = "20%"><u>Example</u></th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>int</td>
|
|
|
|
<td>KDE.versionMajor ()</td>
|
|
|
|
<td align = "center">3</td>
|
|
|
|
<td></td>
|
|
|
|
<td>PyKDE.versionMajor ()</td>
|
|
|
|
<td align = "center">3</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>int</td>
|
|
|
|
<td>KDE.versionMinor ()</td>
|
|
|
|
<td align = "center">1</td>
|
|
|
|
<td></td>
|
|
|
|
<td>PyKDE.versionMinor ()</td>
|
|
|
|
<td align = "center">8</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>int</td>
|
|
|
|
<td>KDE.versionRelease ()</td>
|
|
|
|
<td align = "center">4</td>
|
|
|
|
<td></td>
|
|
|
|
<td>PyKDE.versionRelease ()</td>
|
|
|
|
<td align = "center">0</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>string</td>
|
|
|
|
<td>KDE.versionString ()</td>
|
|
|
|
<td align = "center">"3.1.4"</td>
|
|
|
|
<td></td>
|
|
|
|
<td>PyKDE.versionString ()</td>
|
|
|
|
<td align = "center">"3.11.0"</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<h2>Abstract Classes and Pure Virtual Methods</h2>
|
|
|
|
<P>
|
|
|
|
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.
|
|
|
|
</P>
|
|
|
|
<P>
|
|
|
|
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:
|
|
|
|
</P>
|
|
|
|
<TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%">
|
|
|
|
<TR>
|
|
|
|
<TD>
|
|
|
|
<PRE CLASS="PROGRAMLISTING">
|
|
|
|
virtual int somePureVirtualMethod (int a) = 0;
|
|
|
|
</PRE>
|
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
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.
|
|
|
|
</P>
|
|
|
|
|
|
|
|
<DIV CLASS="NAVFOOTER">
|
|
|
|
<HR ALIGN="LEFT" WIDTH="100%">
|
|
|
|
<TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" >
|
|
|
|
<TR>
|
|
|
|
<TD WIDTH="33%" ALIGN="left" VALIGN="top"><A HREF="signal.html" ACCESSKEY="P">Prev</A></TD>
|
|
|
|
<TD WIDTH="34%" ALIGN="center" VALIGN="top"><A HREF="index.html" ACCESSKEY="H">Home</A></TD>
|
|
|
|
<TD WIDTH="33%" ALIGN="right" VALIGN="top"><A HREF="classref/index.html" ACCESSKEY="N">Next</A></TD>
|
|
|
|
</TR>
|
|
|
|
<TR>
|
|
|
|
<TD WIDTH="33%" ALIGN="left" VALIGN="top">Signals and Slots</TD>
|
|
|
|
<TD WIDTH="34%" ALIGN="center" VALIGN="top"> </TD>
|
|
|
|
<TD WIDTH="33%" ALIGN="right" VALIGN="top">Class Reference</TD>
|
|
|
|
</TR>
|
|
|
|
</TABLE>
|
|
|
|
</DIV>
|
|
|
|
|
|
|
|
</BODY>
|
|
|
|
</HTML>
|