wx.richtext.RichTextFormattingDialog¶
This dialog allows the user to edit a character and/or paragraph style.
In the constructor, specify the pages that will be created. Use wx.richtext.RichTextFormattingDialog.GetStyle
to retrieve the common style for a given range, and then use wx.richtext.RichTextFormattingDialog.ApplyStyle
to apply the user-selected formatting to a control.
For example:
if self.richTextCtrl.HasSelection():
range = self.richTextCtrl.GetSelectionRange()
else:
range = wx.RichTextRange(0, self.richTextCtrl.GetLastPosition()+1)
pages = wx.richtext.RICHTEXT_FORMAT_FONT \
| wx.richtext.RICHTEXT_FORMAT_INDENTS_SPACING \
| wx.richtext.RICHTEXT_FORMAT_TABS \
| wx.richtext.RICHTEXT_FORMAT_BULLETS
with wx.richtext.RichTextFormattingDialog(pages, self) as dlg:
dlg.GetStyle(self.richTextCtrl, range)
if dlg.ShowModal() == wx.ID_OK:
dlg.ApplyStyle(self.richTextCtrl, range)
Class Hierarchy¶
Methods Summary¶
Default constructor. |
|
Apply attributes to the given range, only changing attributes that need to be changed. |
|
Creation: see wx.richtext.RichTextFormattingDialog “the constructor” for details about the parameters. |
|
Returns the custom colour data for use by the colour dialog. |
|
Helper for pages to get the top-level dialog. |
|
Helper for pages to get the attributes. |
|
Helper for pages to get the style. |
|
Returns the object to be used to customize the dialog and provide pages. |
|
Returns the image list associated with the dialog, used for example if showing the dialog as a toolbook. |
|
Returns the page identifier of the last page selected (not the control id). |
|
Gets the dialog options, determining what the interface presents to the user. |
|
Returns |
|
Gets common attributes from the given range and calls |
|
Gets the associated style definition, if any. |
|
Gets the associated style sheet, if any. |
|
Returns |
|
Sets the attributes to be edited. |
|
Sets the custom colour data for use by the colour dialog. |
|
Sets the formatting factory object to be used for customization and page creation. |
|
Sets the image list associated with the dialog’s property sheet. |
|
Sets the page identifier of the last page selected (not the control id). |
|
Sets the dialog options, determining what the interface presents to the user. |
|
Pass |
|
Sets the attributes and optionally updates the display, if update is |
|
Sets the style definition and optionally update the display, if update is |
|
Updates the display. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.richtext.RichTextFormattingDialog(PropertySheetDialog)¶
Possible constructors:
RichTextFormattingDialog() -> None RichTextFormattingDialog(flags, parent, title="Formatting", id=ID_ANY, pos=DefaultPosition, sz=DefaultSize, style=DEFAULT_DIALOG_STYLE) -> None
This dialog allows the user to edit a character and/or paragraph style.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor.
- Return type:
None
__init__ (self, flags, parent, title=”Formatting”, id=ID_ANY, pos=DefaultPosition, sz=DefaultSize, style=DEFAULT_DIALOG_STYLE)
Constructors.
- Parameters:
- Return type:
None
- ApplyStyle(self, ctrl, range, flags=RICHTEXT_SETSTYLE_WITH_UNDO | RICHTEXT_SETSTYLE_OPTIMIZE)¶
Apply attributes to the given range, only changing attributes that need to be changed.
- Parameters:
ctrl (wx.richtext.RichTextCtrl)
range (wx.richtext.RichTextRange)
flags (int)
- Return type:
bool
- Create(self, flags, parent, title=GetTranslation('Formatting'), id=ID_ANY, pos=DefaultPosition, sz=DefaultSize, style=DEFAULT_DIALOG_STYLE)¶
Creation: see wx.richtext.RichTextFormattingDialog “the constructor” for details about the parameters.
- GetAttributes(self)¶
- Return type:
TextAttr
- static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶
- Parameters:
variant (WindowVariant)
- Return type:
VisualAttributes
- static GetColourData()¶
Returns the custom colour data for use by the colour dialog.
- Return type:
ColourData
- static GetDialog(win)¶
Helper for pages to get the top-level dialog.
- Parameters:
win (wx.Window)
- Return type:
- static GetDialogAttributes(win)¶
Helper for pages to get the attributes.
- Parameters:
win (wx.Window)
- Return type:
TextAttr
- static GetDialogStyleDefinition(win)¶
Helper for pages to get the style.
- Parameters:
win (wx.Window)
- Return type:
- static GetFormattingDialogFactory()¶
Returns the object to be used to customize the dialog and provide pages.
- Return type:
- GetImageList(self)¶
Returns the image list associated with the dialog, used for example if showing the dialog as a toolbook.
- Return type:
- static GetLastPage()¶
Returns the page identifier of the last page selected (not the control id).
- Return type:
int
- GetOptions(self)¶
Gets the dialog options, determining what the interface presents to the user.
Currently the only option is Option_AllowPixelFontSize.
- Return type:
int
- static GetRestoreLastPage()¶
Returns
True
if the dialog will restore the last-selected page.- Return type:
bool
- GetStyle(self, ctrl, range)¶
Gets common attributes from the given range and calls
SetAttributes
.Attributes that do not have common values in the given range will be omitted from the style’s flags.
- Parameters:
ctrl (wx.richtext.RichTextCtrl)
range (wx.richtext.RichTextRange)
- Return type:
bool
- GetStyleDefinition(self)¶
Gets the associated style definition, if any.
- Return type:
- GetStyleSheet(self)¶
Gets the associated style sheet, if any.
- Return type:
- HasOption(self, option)¶
Returns
True
if the given option is present.- Parameters:
option (int)
- Return type:
bool
- SetAttributes(self, attr)¶
Sets the attributes to be edited.
- Parameters:
attr (wx.TextAttr)
- Return type:
None
- static SetColourData(colourData)¶
Sets the custom colour data for use by the colour dialog.
- Parameters:
colourData (wx.ColourData)
- Return type:
None
- static SetFormattingDialogFactory(factory)¶
Sets the formatting factory object to be used for customization and page creation.
It deletes the existing factory object.
- Parameters:
- Return type:
None
- SetImageList(self, imageList)¶
Sets the image list associated with the dialog’s property sheet.
- Parameters:
imageList (wx.ImageList)
- Return type:
None
- static SetLastPage(lastPage)¶
Sets the page identifier of the last page selected (not the control id).
- Parameters:
lastPage (int)
- Return type:
None
- SetOptions(self, options)¶
Sets the dialog options, determining what the interface presents to the user.
Currently the only option is Option_AllowPixelFontSize.
- Parameters:
options (int)
- Return type:
None
- static SetRestoreLastPage(b)¶
Pass
True
if the dialog should restore the last-selected page.- Parameters:
b (bool)
- Return type:
None
- SetStyle(self, style, update=True)¶
Sets the attributes and optionally updates the display, if update is
True
.- Parameters:
style (wx.TextAttr)
update (bool)
- Return type:
bool
- SetStyleDefinition(self, styleDef, sheet, update=True)¶
Sets the style definition and optionally update the display, if update is
True
.- Parameters:
styleDef (wx.richtext.RichTextStyleDefinition)
sheet (wx.richtext.RichTextStyleSheet)
update (bool)
- Return type:
bool
- UpdateDisplay(self)¶
Updates the display.
- Return type:
bool
Properties¶
- Attributes¶
See
GetAttributes
andSetAttributes
- ImageList¶
See
GetImageList
andSetImageList
- Options¶
See
GetOptions
andSetOptions
- StyleDefinition¶
See
GetStyleDefinition
andSetStyleDefinition
- StyleSheet¶
See
GetStyleSheet