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)
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. |
|
Gets the attributes being edited. |
|
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. |
|
Gets the dialog options, determining what the interface presents to the user. |
|
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 formatting factory object to be used for customization and page creation. |
|
Sets the image list associated with the dialog’s property sheet. |
|
Sets the dialog options, determining what the interface presents to the user. |
|
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¶wx.richtext.RichTextFormattingDialog(PropertySheetDialog)¶Possible constructors:
RichTextFormattingDialog()
RichTextFormattingDialog(flags, parent, title="Formatting", id=ID_ANY,
pos=DefaultPosition, sz=DefaultSize, style=DEFAULT_DIALOG_STYLE)
This dialog allows the user to edit a character and/or paragraph style.
__init__(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, flags, parent, title=”Formatting”, id=ID_ANY, pos=DefaultPosition, sz=DefaultSize, style=DEFAULT_DIALOG_STYLE)
Constructors.
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.
ctrl (wx.richtext.RichTextCtrl) –
range (wx.richtext.RichTextRange) –
flags (int) –
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)¶Gets the attributes being edited.
TextAttr
GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
VisualAttributes
GetDialog(win)¶Helper for pages to get the top-level dialog.
win (wx.Window) –
GetDialogAttributes(win)¶Helper for pages to get the attributes.
win (wx.Window) –
TextAttr
GetDialogStyleDefinition(win)¶Helper for pages to get the style.
win (wx.Window) –
GetFormattingDialogFactory()¶Returns the object to be used to customize the dialog and provide pages.
GetImageList(self)¶Returns the image list associated with the dialog, used for example if showing the dialog as a toolbook.
GetOptions(self)¶Gets the dialog options, determining what the interface presents to the user.
Currently the only option is Option_AllowPixelFontSize.
int
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.
ctrl (wx.richtext.RichTextCtrl) –
range (wx.richtext.RichTextRange) –
bool
GetStyleDefinition(self)¶Gets the associated style definition, if any.
GetStyleSheet(self)¶Gets the associated style sheet, if any.
HasOption(self, option)¶Returns True if the given option is present.
option (int) –
bool
SetAttributes(self, attr)¶Sets the attributes to be edited.
attr (wx.TextAttr) –
SetFormattingDialogFactory(factory)¶Sets the formatting factory object to be used for customization and page creation.
It deletes the existing factory object.
factory (wx.richtext.RichTextFormattingDialogFactory) –
SetImageList(self, imageList)¶Sets the image list associated with the dialog’s property sheet.
imageList (wx.ImageList) –
SetOptions(self, options)¶Sets the dialog options, determining what the interface presents to the user.
Currently the only option is Option_AllowPixelFontSize.
options (int) –
SetStyle(self, style, update=True)¶Sets the attributes and optionally updates the display, if update is True.
style (wx.TextAttr) –
update (bool) –
bool
SetStyleDefinition(self, styleDef, sheet, update=True)¶Sets the style definition and optionally update the display, if update is True.
styleDef (wx.richtext.RichTextStyleDefinition) –
sheet (wx.richtext.RichTextStyleSheet) –
update (bool) –
bool
UpdateDisplay(self)¶Updates the display.
bool
Attributes¶See GetAttributes and SetAttributes
ImageList¶See GetImageList and SetImageList
Options¶See GetOptions and SetOptions
StyleDefinition¶See GetStyleDefinition and SetStyleDefinition
StyleSheet¶See GetStyleSheet