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)
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. |
|
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. |
See |
|
See |
|
See |
|
See |
|
See |
wx.richtext.
RichTextFormattingDialog
(PropertySheetDialog)¶Possible constructors:
RichTextFormattingDialog() -> None
RichTextFormattingDialog(flags : int, parent : Window, title:
str="Formatting", id: int=ID_ANY, pos: Point=DefaultPosition, sz:
Size=DefaultSize, style: int=DEFAULT_DIALOG_STYLE) -> None
This dialog allows the user to edit a character and/or paragraph style.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
None
__init__ (self, flags : int, parent : Window, title: str=”Formatting”, id: int=ID_ANY, pos: Point=DefaultPosition, sz: Size=DefaultSize, style: int=DEFAULT_DIALOG_STYLE)
Constructors.
None
ApplyStyle
(self, ctrl : RichTextCtrl, range : RichTextRange, flags: int=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 : int, parent : Window, title: str=GetTranslation("Formatting"), id: int=ID_ANY, pos: Point=DefaultPosition, sz: Size=DefaultSize, style: int=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: WindowVariant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
VisualAttributes
GetColourData
()¶Returns the custom colour data for use by the colour dialog.
ColourData
GetDialog
(win : Window)¶Helper for pages to get the top-level dialog.
win (wx.Window) –
GetDialogAttributes
(win : Window)¶Helper for pages to get the attributes.
win (wx.Window) –
TextAttr
GetDialogStyleDefinition
(win : Window)¶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.
GetLastPage
()¶Returns the page identifier of the last page selected (not the control id).
int
GetOptions
(self)¶Gets the dialog options, determining what the interface presents to the user.
Currently the only option is Option_AllowPixelFontSize.
int
GetRestoreLastPage
()¶Returns True
if the dialog will restore the last-selected page.
bool
GetStyle
(self, ctrl : RichTextCtrl, range : RichTextRange)¶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 : int)¶Returns True
if the given option is present.
option (int) –
bool
SetAttributes
(self, attr : TextAttr)¶Sets the attributes to be edited.
attr (wx.TextAttr) –
None
SetColourData
(colourData : ColourData)¶Sets the custom colour data for use by the colour dialog.
colourData (wx.ColourData) –
None
SetFormattingDialogFactory
(factory : RichTextFormattingDialogFactory)¶Sets the formatting factory object to be used for customization and page creation.
It deletes the existing factory object.
factory (wx.richtext.RichTextFormattingDialogFactory) –
None
SetImageList
(self, imageList : ImageList)¶Sets the image list associated with the dialog’s property sheet.
imageList (wx.ImageList) –
None
SetLastPage
(lastPage : int)¶Sets the page identifier of the last page selected (not the control id).
lastPage (int) –
None
SetOptions
(self, options : int)¶Sets the dialog options, determining what the interface presents to the user.
Currently the only option is Option_AllowPixelFontSize.
options (int) –
None
SetRestoreLastPage
(b : bool)¶Pass True
if the dialog should restore the last-selected page.
b (bool) –
None
SetStyle
(self, style : TextAttr, update: bool=True)¶Sets the attributes and optionally updates the display, if update is True
.
style (wx.TextAttr) –
update (bool) –
bool
SetStyleDefinition
(self, styleDef : RichTextStyleDefinition, sheet : RichTextStyleSheet, update: bool=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