KRichTextWidget Class Reference
from PyKDE4.kdeui import *
Inherits: KRichTextEdit → KTextEdit → QTextEdit → QAbstractScrollArea → QFrame → QWidget → QObject
Detailed Description
A KRichTextEdit with common actions
This class implements common actions which are often used with KRichTextEdit. All you need to do is to call createActions(), and the actions will be added to your KXMLGUIWindow. Remember to also add the chosen actions to your application ui.rc file.
See the KRichTextWidget.RichTextSupportValues enum for an overview of supported actions.

"KDE Rich Text Widget"
- Since:
- 4.1
Enumerations | |
RichTextSupportValues | { DisableRichText, SupportBold, SupportItalic, SupportUnderline, SupportStrikeOut, SupportFontFamily, SupportFontSize, SupportTextForegroundColor, SupportTextBackgroundColor, FullTextFormattingSupport, SupportChangeListStyle, SupportIndentLists, SupportDedentLists, FullListSupport, SupportAlignment, SupportRuleLine, SupportHyperlinks, SupportFormatPainting, SupportToPlainText, SupportSuperScriptAndSubScript, FullSupport } |
Methods | |
__init__ (self, QWidget parent) | |
__init__ (self, QString text, QWidget parent=0) | |
createActions (self, KActionCollection actionCollection) | |
mouseReleaseEvent (self, QMouseEvent event) | |
KRichTextWidget.RichTextSupport | richTextSupport (self) |
setActionsEnabled (self, bool enabled) | |
setRichTextSupport (self, KRichTextWidget.RichTextSupport support) | |
updateActionStates (self) |
Method Documentation
__init__ | ( | self, | ||
QWidget | parent | |||
) |
createActions | ( | self, | ||
KActionCollection | actionCollection | |||
) |
Creates the actions and adds them to the given action collection.
Call this before calling setupGUI() in your application, but after calling setRichTextSupport().
The XML file of your KXmlGuiWindow needs to have the action names in them, so that the actions actually appear in the menu and in the toolbars.
Below is a list of actions that are created,depending on the supported rich text subset set by setRichTextSupport(). The list contains action names. Those names need to be the same in your XML file.
See the KRichTextWidget.RichTextSupportValues enum documentation for a detailed explaination of each action.
<table> <tr><td>XML Name</td><td>RichTextSupportValues flag</td></tr> <tr><td>format_text_foreground_color</td><td>SupportTextForegroundColor</td></tr> <tr><td>format_text_background_color</td><td>SupportTextBackgroundColor</td></tr> <tr><td>format_font_family</td><td>SupportFontFamily</td></tr> <tr><td>format_font_size</td><td>SupportFontSize</td></tr> <tr><td>format_text_bold</td><td>SupportBold</td></tr> <tr><td>format_text_italic</td><td>SupportItalic</td></tr> <tr><td>format_text_underline</td><td>SupportUnderline</td></tr> <tr><td>format_text_strikeout</td><td>SupportStrikeOut</td></tr> <tr><td>format_align_left</td><td>SupportAlignment</td></tr> <tr><td>format_align_center</td><td>SupportAlignment</td></tr> <tr><td>format_align_right</td><td>SupportAlignment</td></tr> <tr><td>format_align_justify</td><td>SupportAlignment</td></tr> <tr><td>format_list_style</td><td>SupportChangeListStyle</td></tr> <tr><td>format_list_indent_more</td><td>SupportIndentLists</td></tr> <tr><td>format_list_indent_less</td><td>SupportDedentLists</td></tr> <tr><td>insert_horizontal_rule</td><td>SupportRuleLine</td></tr> <tr><td>manage_link</td><td>SupportHyperlinks</td></tr> <tr><td>format_painter</td><td>SupportFormatPainting</td></tr> <tr><td>action_to_plain_text</td><td>SupportToPlainText</td></tr> <tr><td>format_text_subscript & format_text_superscript</td><td>SupportSuperScriptAndSubScript</td></tr> </table>
- Parameters:
-
actionCollection the actions will be added to this action collection
mouseReleaseEvent | ( | self, | ||
QMouseEvent | event | |||
) |
Reimplemented. Catches mouse release events. Used to know when a selection has been completed.
KRichTextWidget.RichTextSupport richTextSupport | ( | self ) |
Returns the supported rich text subset available.
- Returns:
- The supported subset.
setActionsEnabled | ( | self, | ||
bool | enabled | |||
) |
Disables or enables all of the actions created by createActions(). This may be useful in cases where rich text mode may be set on or off.
- Parameters:
-
enabled Whether to enable or disable the actions.
setRichTextSupport | ( | self, | ||
KRichTextWidget.RichTextSupport | support | |||
) |
Sets the supported rich text subset available.
The default is KRichTextWidget.FullSupport and will be set in the constructor.
You need to call createActions() afterwards.
- Parameters:
-
support The supported subset.
updateActionStates | ( | self ) |
Tells KRichTextWidget to update the state of the actions created by createActions(). This is normally automatically done, but there might be a few cases where you'll need to manually call this function.
Call this function only after calling createActions().
Enumeration Documentation
RichTextSupportValues |
- Enumerator:
-