Phoenix Logo

phoenix_title 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 Class Hierarchy

Inheritance diagram for class RichTextFormattingDialog:


method_summary Methods Summary

__init__ Default constructor.
ApplyStyle Apply attributes to the given range, only changing attributes that need to be changed.
Create Creation: see wx.richtext.RichTextFormattingDialog “the constructor” for details about the parameters.
GetAttributes Gets the attributes being edited.
GetDialog Helper for pages to get the top-level dialog.
GetDialogAttributes Helper for pages to get the attributes.
GetDialogStyleDefinition Helper for pages to get the style.
GetFormattingDialogFactory Returns the object to be used to customize the dialog and provide pages.
GetImageList Returns the image list associated with the dialog, used for example if showing the dialog as a toolbook.
GetOptions Gets the dialog options, determining what the interface presents to the user.
GetStyle Gets common attributes from the given range and calls SetAttributes .
GetStyleDefinition Gets the associated style definition, if any.
GetStyleSheet Gets the associated style sheet, if any.
HasOption Returns True if the given option is present.
SetAttributes Sets the attributes to be edited.
SetFormattingDialogFactory Sets the formatting factory object to be used for customization and page creation.
SetImageList Sets the image list associated with the dialog’s property sheet.
SetOptions Sets the dialog options, determining what the interface presents to the user.
SetStyle Sets the attributes and optionally updates the display, if update is True.
SetStyleDefinition Sets the style definition and optionally update the display, if update is True.
UpdateDisplay Updates the display.

api Class API



class 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.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.



__init__ (self, flags, parent, title=”Formatting”, id=ID_ANY, pos=DefaultPosition, sz=DefaultSize, style=DEFAULT_DIALOG_STYLE)

Constructors.

Parameters:
  • flags (long) – The pages to show.
  • parent (wx.Window) – The dialog’s parent.
  • title (string) – The dialog’s title.
  • id (wx.WindowID) – The dialog’s ID.
  • pos (wx.Point) – The dialog’s position.
  • sz (wx.Size) – The dialog’s size.
  • style (long) – The dialog’s window style.





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:
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.

Parameters:
  • flags (long) –
  • parent (wx.Window) –
  • title (string) –
  • id (wx.WindowID) –
  • pos (wx.Point) –
  • sz (wx.Size) –
  • style (long) –
Return type:

bool



GetAttributes(self)

Gets the attributes being edited.

Return type:TextAttr


static GetDialog(win)

Helper for pages to get the top-level dialog.

Parameters:win (wx.Window) –
Return type: wx.richtext.RichTextFormattingDialog


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: wx.richtext.RichTextStyleDefinition


static GetFormattingDialogFactory()

Returns the object to be used to customize the dialog and provide pages.

Return type: wx.richtext.RichTextFormattingDialogFactory


GetImageList(self)

Returns the image list associated with the dialog, used for example if showing the dialog as a toolbook.

Return type:ImageList


GetOptions(self)

Gets the dialog options, determining what the interface presents to the user.

Currently the only option is Option_AllowPixelFontSize.

Return type: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.

Parameters:
Return type:

bool



GetStyleDefinition(self)

Gets the associated style definition, if any.

Return type: wx.richtext.RichTextStyleDefinition


GetStyleSheet(self)

Gets the associated style sheet, if any.

Return type: wx.richtext.RichTextStyleSheet


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) –


static SetFormattingDialogFactory(factory)

Sets the formatting factory object to be used for customization and page creation.

It deletes the existing factory object.

Parameters:factory (wx.richtext.RichTextFormattingDialogFactory) –


SetImageList(self, imageList)

Sets the image list associated with the dialog’s property sheet.

Parameters: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.

Parameters:options (int) –


SetStyle(self, style, update=True)

Sets the attributes and optionally updates the display, if update is True.

Parameters:
Return type:

bool



SetStyleDefinition(self, styleDef, sheet, update=True)

Sets the style definition and optionally update the display, if update is True.

Parameters:
Return type:

bool



UpdateDisplay(self)

Updates the display.

Return type:bool

Properties



Attributes

See GetAttributes and SetAttributes



ImageList

See GetImageList and SetImageList



Options

See GetOptions and SetOptions



StyleDefinition

See GetStyleDefinition and SetStyleDefinition



StyleSheet

See GetStyleSheet