wx.TextAttr represents the character and paragraph attributes, or style, for a range of text in a wx.TextCtrl or wx.richtext.RichTextCtrl.
Unless explicitly mentioned, the attributes are only implemented in wx.richtext.RichTextCtrl, and not wx.TextCtrl.
When setting up a wx.TextAttr object, pass a bitlist mask to wx.TextAttr.SetFlags
to indicate which style elements should be changed. As a convenience, when you call a setter such as SetFont, the relevant bit will be set.
See also
Constructors. |
|
Applies the attributes in style to the original object, but not those attributes from style that are the same as those in compareWith (if passed). |
|
Partial equality test. |
|
Returns the alignment flags. |
|
Returns the background colour. |
|
Returns a string containing the name of the font associated with the bullet symbol. |
|
Returns the standard bullet name, applicable if the bullet style is |
|
Returns the bullet number. |
|
Returns the bullet style. |
|
Returns the bullet text, which could be a symbol, or (for example) cached outline text. |
|
Returns the name of the character style. |
|
Returns flags indicating which attributes are applicable. |
|
Creates and returns a font specified by the font attributes in the wx.TextAttr object. |
|
Gets the font attributes from the given font, using only the attributes specified by flags. |
|
Returns the font encoding. |
|
Returns the font face name. |
|
Returns the font family. |
|
Returns the font size in points. |
|
Returns the font style. |
|
Returns |
|
Returns the font weight. |
|
Returns the left indent in tenths of a millimetre. |
|
Returns the left sub-indent in tenths of a millimetre. |
|
Returns the line spacing value, one of wx.TextAttrLineSpacing values. |
|
Returns the name of the list style. |
|
Returns the outline level. |
|
Returns the space in tenths of a millimeter after the paragraph. |
|
Returns the space in tenths of a millimeter before the paragraph. |
|
Returns the name of the paragraph style. |
|
Returns the right indent in tenths of a millimeter. |
|
Returns an array of tab stops, each expressed in tenths of a millimeter. |
|
Returns the text foreground colour. |
|
Returns the text effect bits of interest. |
|
Returns the text effects, a bit list of styles. |
|
Returns the URL for the content. |
|
Returns the underline color used. |
|
Returns the underline type, which is one of the TextAttrUnderlineType values. |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Copies all defined/valid properties from overlay to current object. |
|
Sets the paragraph alignment. |
|
Sets the background colour. |
|
Sets the name of the font associated with the bullet symbol. |
|
Sets the standard bullet name, applicable if the bullet style is |
|
Sets the bullet number. |
|
Sets the bullet style. |
|
Sets the bullet text, which could be a symbol, or (for example) cached outline text. |
|
Sets the character style name. |
|
Sets the flags determining which styles are being specified. |
|
Sets the attributes for the given font. |
|
Sets the font encoding. |
|
Sets the font face name. |
|
Sets the font family. |
|
Sets the font size in pixels. |
|
Sets the font size in points. |
|
Sets the font size in points. |
|
Sets the font style (normal, italic or slanted). |
|
Sets the font underlining (solid line, text colour). |
|
Sets the font underlining. |
|
Sets the font weight. |
|
Sets the left indent and left subindent in tenths of a millimetre. |
|
Sets the line spacing. |
|
Sets the list style name. |
|
Specifies the outline level. |
|
Specifies a page break before this paragraph. |
|
Sets the spacing after a paragraph, in tenths of a millimetre. |
|
Sets the spacing before a paragraph, in tenths of a millimetre. |
|
Sets the name of the paragraph style. |
|
Sets the right indent in tenths of a millimetre. |
|
Sets the tab stops, expressed in tenths of a millimetre. |
|
Sets the text foreground colour. |
|
Sets the text effect bits of interest. |
|
Sets the text effects, a bit list of styles. |
|
Sets the URL for the content. |
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
Possible constructors:
TextAttr() -> None
TextAttr(colText : Colour, colBack: Colour=NullColour, font:
Font=NullFont, alignment: TextAttrAlignment=TEXT_ALIGNMENT_DEFAULT) ->
None
TextAttr(attr : TextAttr) -> None
TextAttr represents the character and paragraph attributes, or style, for a range of text in a TextCtrl or RichTextCtrl.
Constructors.
__init__ (self)
None
__init__ (self, colText : Colour, colBack: Colour=NullColour, font: Font=NullFont, alignment: TextAttrAlignment=TEXT_ALIGNMENT_DEFAULT)
colText (wx.Colour)
colBack (wx.Colour)
font (wx.Font)
alignment (TextAttrAlignment)
None
__init__ (self, attr : TextAttr)
attr (wx.TextAttr)
None
Applies the attributes in style to the original object, but not those attributes from style that are the same as those in compareWith (if passed).
style (wx.TextAttr)
compareWith (wx.TextAttr)
bool
Partial equality test.
If weakTest is True
, attributes of this object do not have to be present if those attributes of attr
are present. If weakTest is False
, the function will fail if an attribute is present in attr
but not in this object.
attr (wx.TextAttr)
weakTest (bool)
bool
Returns the alignment flags.
See wx.TextAttrAlignment for a list of available styles.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
Returns the background colour.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
Returns a string containing the name of the font associated with the bullet symbol.
Only valid for attributes with TEXT_ATTR_BULLET_SYMBOL
.
str
Returns the standard bullet name, applicable if the bullet style is wx.TEXT_ATTR_BULLET_STYLE_STANDARD
.
Currently the following standard bullet names are supported:
standard/circle
standard/square
standard/diamond
standard/triangle
str
Note
For wx.richtext.RichTextCtrl users only: if you wish your rich text controls to support further bullet graphics, you can derive a class from wx.richtext.RichTextRenderer or wx.richtext.RichTextStdRenderer, override DrawStandardBullet
and EnumerateStandardBulletNames
, and set an instance of the class using wx.richtext.RichTextBuffer.SetRenderer
.
Returns the bullet number.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
int
Returns the bullet style.
See wx.TextAttrBulletStyle for a list of available styles.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
int
Returns the bullet text, which could be a symbol, or (for example) cached outline text.
str
Returns the name of the character style.
str
Returns flags indicating which attributes are applicable.
See SetFlags
for a list of available flags.
int
Creates and returns a font specified by the font attributes in the wx.TextAttr object.
Note that wx.TextAttr does not store a wx.Font object, so this is only a temporary font.
For greater efficiency, access the font attributes directly.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
Gets the font attributes from the given font, using only the attributes specified by flags.
font (wx.Font)
flags (int)
bool
Returns the font encoding.
Returns the font face name.
str
Returns the font family.
Returns the font size in points.
int
Returns the font style.
Returns True
if the font is underlined.
bool
Returns the font weight.
Returns the left indent in tenths of a millimetre.
For wx.TextCtrl, is implemented under wxMSW and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
int
Returns the left sub-indent in tenths of a millimetre.
For wx.TextCtrl, is implemented under wxMSW and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
int
Returns the line spacing value, one of wx.TextAttrLineSpacing values.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
int
Returns the name of the list style.
str
Returns the outline level.
int
Returns the space in tenths of a millimeter after the paragraph.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
int
Returns the space in tenths of a millimeter before the paragraph.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
int
Returns the name of the paragraph style.
str
Returns the right indent in tenths of a millimeter.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
int
Returns an array of tab stops, each expressed in tenths of a millimeter.
Each stop is measured from the left margin and therefore each value must be larger than the last.
For wx.TextCtrl, is implemented under wxMSW and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
List[int]
Returns the text foreground colour.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
Returns the text effect bits of interest.
See SetFlags
for further information.
int
Returns the text effects, a bit list of styles.
See SetTextEffects
for details.
int
Returns the URL for the content.
Content with wx.TEXT_ATTR_URL
style causes wx.richtext.RichTextCtrl to show a hand cursor over it, and wx.richtext.RichTextCtrl generates a wx.TextUrlEvent when the content is clicked.
str
Returns the underline color used.
NullColour when the text colour is used.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
Added in version 4.1/wxWidgets-3.1.3.
Returns the underline type, which is one of the TextAttrUnderlineType values.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
Added in version 4.1/wxWidgets-3.1.3.
Returns True
if the attribute object specifies alignment.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies a background colour.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies a standard bullet name.
bool
Returns True
if the attribute object specifies a bullet number.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies a bullet style.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies bullet text (usually specifying a symbol).
bool
Returns True
if the attribute object specifies a character style name.
bool
Returns True
if the flag is present in the attribute object’s flag bitlist.
flag (long)
bool
Returns True
if the attribute object specifies any font attributes.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies an encoding.
bool
Returns True
if the attribute object specifies a font face name.
bool
Returns True
if the attribute object specifies a font family.
bool
Returns True
if the attribute object specifies italic style.
bool
Returns True
if the attribute object specifies a font pixel size.
bool
Returns True
if the attribute object specifies a font point size.
bool
Returns True
if the attribute object specifies a font point or pixel size.
bool
Returns True
if the attribute object specifies either underlining or no underlining.
bool
Returns True
if the attribute object specifies font weight (bold, light or normal).
bool
Returns True
if the attribute object specifies a left indent.
For wx.TextCtrl, is implemented under wxMSW and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies line spacing.
For wx.TextCtrl, is implemented under wxMSW and wxOSX. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies a list style name.
bool
Returns True
if the attribute object specifies an outline level.
bool
Returns True
if the attribute object specifies a page break before this paragraph.
bool
Returns True
if the attribute object specifies spacing after a paragraph.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies spacing before a paragraph.
For wx.TextCtrl, is implemented under wxMSW and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies a paragraph style name.
bool
Returns True
if the attribute object specifies a right indent.
bool
Returns True
if the attribute object specifies tab stops.
For wx.TextCtrl, is implemented under wxMSW and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies a text foreground colour.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
bool
Returns True
if the attribute object specifies text effects.
bool
Returns True
if the attribute object specifies a URL.
bool
Returns True
if the object represents a character style, that is, the flags specify a font or a text background or foreground colour.
bool
Returns False
if we have any attributes set, True
otherwise.
bool
Returns True
if the object represents a paragraph style, that is, the flags specify alignment, indentation, tabs, paragraph spacing, or bullet style.
bool
Merge (self, overlay : TextAttr)
Copies all defined/valid properties from overlay to current object.
overlay (wx.TextAttr)
None
Merge (base : TextAttr, overlay : TextAttr)
Creates a new wx.TextAttr which is a merge of base and overlay.
Properties defined in overlay take precedence over those in base. Properties undefined/invalid in both are undefined in the result.
base (wx.TextAttr)
overlay (wx.TextAttr)
Sets the paragraph alignment.
See wx.TextAttrAlignment enumeration values.
wx.TEXT_ALIGNMENT_JUSTIFIED
is not implemented for wx.richtext.RichTextCtrl. In the future, wx.richtext.RichTextCtrl justification may be supported when printing or previewing only.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
alignment (TextAttrAlignment)
None
Sets the background colour.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
colBack (wx.Colour)
None
Sets the name of the font associated with the bullet symbol.
Only valid for attributes with TEXT_ATTR_BULLET_SYMBOL
.
font (string)
None
Sets the standard bullet name, applicable if the bullet style is wx.TEXT_ATTR_BULLET_STYLE_STANDARD
.
See GetBulletName
for a list of supported names, and how to expand the range of supported types.
name (string)
None
Sets the bullet number.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
n (int)
None
Sets the bullet style.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
For wx.richtext.RichTextCtrl, the wx.TextAttrBulletStyle enumeration values are all supported, except for wx.TEXT_ATTR_BULLET_STYLE_BITMAP
.
For wx.TextCtrl under wxMSW, the wx.TextAttrBulletStyle enumeration values are all supported, except for wx.TEXT_ATTR_BULLET_STYLE_BITMAP
, wx.TEXT_ATTR_BULLET_STYLE_OUTLINE
, wx.TEXT_ATTR_BULLET_STYLE_ALIGN_LEFT
, wx.TEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
, wx.TEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE
, and wx.TEXT_ATTR_BULLET_STYLE_CONTINUATION
.
style (int)
None
Sets the bullet text, which could be a symbol, or (for example) cached outline text.
text (string)
None
Sets the character style name.
name (string)
None
Sets the flags determining which styles are being specified.
The wx.TextAttrFlags values can be passed in a bitlist.
flags (long)
None
Sets the attributes for the given font.
Note that wx.TextAttr does not store an actual wx.Font object.
For wx.TextCtrl, is implemented under wxMSW, wxOSX and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
font (wx.Font)
flags (int)
Sets the font encoding.
encoding (FontEncoding)
None
Sets the font face name.
faceName (string)
None
Sets the font family.
family (FontFamily)
None
Sets the font size in pixels.
pixelSize (int)
None
Sets the font size in points.
pointSize (int)
None
Sets the font size in points.
pointSize (int)
None
Sets the font style (normal, italic or slanted).
fontStyle (FontStyle)
None
Sets the font underlining (solid line, text colour).
underlined (bool)
None
Sets the font underlining.
type (TextAttrUnderlineType) – Type of underline.
colour (wx.Colour) – Colour to use for underlining, text colour is used by default.
None
Added in version 4.1/wxWidgets-3.1.3.
Note
On wxMSW, wx.TEXT_ATTR_UNDERLINE_DOUBLE
is shown as wx.TEXT_ATTR_UNDERLINE_SOLID
. There is only a limited number of colours supported, the RGB
values are listed here. wx.TEXT_ATTR_UNDERLINE_SPECIAL
is shown as a waved line.
Note
On wxGTK, underline colour is only supported by GTK3
. wx.TEXT_ATTR_UNDERLINE_SPECIAL
is shown as a waved line. GTK might overrule the colour of wx.TEXT_ATTR_UNDERLINE_SPECIAL
.
Note
On wxOSX, wx.TEXT_ATTR_UNDERLINE_SPECIAL
is shown as a dotted line.
Sets the font weight.
fontWeight (FontWeight)
None
Sets the left indent and left subindent in tenths of a millimetre.
The sub-indent is an offset from the left of the paragraph, and is used for all but the first line in a paragraph.
A positive value will cause the first line to appear to the left of the subsequent lines, and a negative value will cause the first line to be indented relative to the subsequent lines.
wx.richtext.RichTextBuffer uses indentation to render a bulleted item. The left indent is the distance between the margin and the bullet. The content of the paragraph, including the first line, starts at leftMargin + leftSubIndent. So the distance between the left edge of the bullet and the left of the actual paragraph is leftSubIndent.
For wx.TextCtrl, is implemented under wxMSW and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
indent (int)
subIndent (int)
None
Sets the line spacing.
spacing is a multiple, where 10 means single-spacing, 15 means 1.5 spacing, and 20 means float spacing. The wx.TextAttrLineSpacing values are defined for convenience.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
spacing (int)
None
Sets the list style name.
name (string)
None
Specifies the outline level.
Zero represents normal text. At present, the outline level is not used, but may be used in future for determining list levels and for applications that need to store document structure information.
level (int)
None
Specifies a page break before this paragraph.
pageBreak (bool)
None
Sets the spacing after a paragraph, in tenths of a millimetre.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
spacing (int)
None
Sets the spacing before a paragraph, in tenths of a millimetre.
For wx.TextCtrl, is implemented under wxMSW. Also implemented in wx.richtext.RichTextCtrl.
spacing (int)
None
Sets the name of the paragraph style.
name (string)
None
Sets the right indent in tenths of a millimetre.
indent (int)
None
Sets the tab stops, expressed in tenths of a millimetre.
Each stop is measured from the left margin and therefore each value must be larger than the last.
For wx.TextCtrl, is implemented under wxMSW and wxGTK. Also implemented in wx.richtext.RichTextCtrl.
tabs (list of integers)
None
Sets the text foreground colour.
colText (wx.Colour)
None
Sets the text effect bits of interest.
You should also pass wx.TEXT_ATTR_EFFECTS
to SetFlags
. See SetFlags
for further information.
flags (int)
None
Sets the text effects, a bit list of styles.
The wx.TextAttrEffects enumeration values can be used.
Of these, only wx.TEXT_ATTR_EFFECT_CAPITALS
, wx.TEXT_ATTR_EFFECT_STRIKETHROUGH
, wx.TEXT_ATTR_EFFECT_SUPERSCRIPT
and wx.TEXT_ATTR_EFFECT_SUBSCRIPT
are implemented.
wx.TEXT_ATTR_EFFECT_CAPITALS
capitalises text when displayed (leaving the case of the actual buffer text unchanged), and wx.TEXT_ATTR_EFFECT_STRIKETHROUGH
draws a line through text.
To set effects, you should also pass wx.TEXT_ATTR_EFFECTS
to SetFlags
, and call SetTextEffectFlags
with the styles (taken from the above set) that you are interested in setting.
effects (int)
None
Sets the URL for the content.
Sets the wx.TEXT_ATTR_URL
style; content with this style causes wx.richtext.RichTextCtrl to show a hand cursor over it, and wx.richtext.RichTextCtrl generates a wx.TextUrlEvent when the content is clicked.
url (string)
None
See GetAlignment
and SetAlignment
See GetBulletFont
and SetBulletFont
See GetBulletName
and SetBulletName
See GetBulletNumber
and SetBulletNumber
See GetBulletStyle
and SetBulletStyle
See GetBulletText
and SetBulletText
See GetFontEncoding
and SetFontEncoding
See GetFontFaceName
and SetFontFaceName
See GetFontFamily
and SetFontFamily
See GetFontSize
and SetFontSize
See GetFontStyle
and SetFontStyle
See GetFontUnderlined
and SetFontUnderlined
See GetFontWeight
and SetFontWeight
See GetLeftIndent
and SetLeftIndent
See GetLeftSubIndent
See GetLineSpacing
and SetLineSpacing
See GetListStyleName
and SetListStyleName
See GetOutlineLevel
and SetOutlineLevel
See GetRightIndent
and SetRightIndent
See GetTextColour
and SetTextColour
See GetTextEffectFlags
and SetTextEffectFlags
See GetTextEffects
and SetTextEffects
See GetUnderlineType