KDE 4.9 PyKDE API Reference

- KDE's Python API

# TextExtension Class Reference

`from PyKDE4.kparts import *`

Inherits: QObject
Namespace: KParts

## Detailed Description

an extension for KParts that allows to retrieve text from the part.

For instance, the text-to-speech plugin uses this to speak the whole text from the part or the selected text. The translation plugin uses it for translating the selected text, and so on.

Since:
  4.6

## Enumerations
Format | { PlainText, HTML }
## Signals
| selectionChanged ()
## Methods
| __init__ (self, KParts.ReadOnlyPart parent)
QString | completeText (self, KParts.TextExtension.Format format)
int | currentPage (self)
bool | findText (self, QString string, KFind.SearchOptions options)
bool | hasSelection (self)
int | pageCount (self)
QString | pageText (self, KParts.TextExtension.Format format)
QString | selectedText (self, KParts.TextExtension.Format format)
## Static Methods
KParts.TextExtension | childObject (QObject obj)

## Signal Documentation

selectionChanged | ( |  | ) |

This signal is emitted when the selection changes.

Signal syntax:
  `QObject.connect(source, SIGNAL("selectionChanged()"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | KParts.ReadOnlyPart | parent
| ) |  |  |

QString completeText | ( | self, |
|  | KParts.TextExtension.Format | format
| ) |  |  |

Returns the complete text shown in the part, in the requested format. If the format is not supported, the part must return an empty string.

int currentPage | ( |  | self ) |

Returns the current page (between 0 and pageCount()-1), for parts who support the concept of pages. Otherwise returns 0.

bool findText | ( | self, |
|  | QString | string,
|  | KFind.SearchOptions | options
| ) |  |  |

Returns true if string is found using the given options.

If any text matches string, then it will be selected/highlighted. To find the next matching text, simply call this function again with the same search text until it returns false.

To clear a selection, just pass an empty string.

Note that parts that implement this extension might not support all the options available in KFind.SearchOptions.

bool hasSelection | ( |  | self ) |

Returns true if the user selected text in the part.

int pageCount | ( |  | self ) |

Returns the number of pages, for parts who support the concept of pages. Otherwise returns 0.

QString pageText | ( | self, |
|  | KParts.TextExtension.Format | format
| ) |  |  |

Returns the text in a given page, in the requested format.

QString selectedText | ( | self, |
|  | KParts.TextExtension.Format | format
| ) |  |  |

Returns the selected text, in the requested format. If the format is not supported, the part must return an empty string.

## Static Method Documentation

KParts.TextExtension childObject | ( | QObject | obj
| ) |  |  |

Queries obj for a child object which inherits from this TextExtension class.

## Enumeration Documentation

Format

Enumerator:

  PlainText |
  HTML |