wx.TextAttr represents the character and paragraph attributes, or style, for a range of text in a wx.TextCtrl or wx.richtext.RichTextCtrl.
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 |
|
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. |
|
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 |
|
wx.
TextAttr
(object)¶Possible constructors:
TextAttr()
TextAttr(colText, colBack=NullColour, font=NullFont,
alignment=TEXT_ALIGNMENT_DEFAULT)
TextAttr(attr)
TextAttr represents the character and paragraph attributes, or style, for a range of text in a TextCtrl or RichTextCtrl.
__init__
(self, *args, **kw)¶Constructors.
__init__ (self)
__init__ (self, colText, colBack=NullColour, font=NullFont, alignment=TEXT_ALIGNMENT_DEFAULT)
colText (wx.Colour) –
colBack (wx.Colour) –
font (wx.Font) –
alignment (TextAttrAlignment) –
__init__ (self, attr)
attr (wx.TextAttr) –
Apply
(self, style, compareWith=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
EqPartial
(self, attr, weakTest=True)¶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
GetAlignment
(self)¶Returns the alignment flags.
See wx.TextAttrAlignment for a list of available styles.
GetBulletFont
(self)¶Returns a string containing the name of the font associated with the bullet symbol.
Only valid for attributes with TEXT_ATTR_BULLET_SYMBOL
.
string
GetBulletName
(self)¶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
string
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
.
GetBulletNumber
(self)¶Returns the bullet number.
int
GetBulletStyle
(self)¶Returns the bullet style.
See wx.TextAttrBulletStyle for a list of available styles.
int
GetBulletText
(self)¶Returns the bullet text, which could be a symbol, or (for example) cached outline text.
string
GetCharacterStyleName
(self)¶Returns the name of the character style.
string
GetFlags
(self)¶Returns flags indicating which attributes are applicable.
See SetFlags
for a list of available flags.
long
GetFont
(self)¶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.
GetFontAttributes
(self, font, flags=TEXT_ATTR_FONT)¶Gets the font attributes from the given font, using only the attributes specified by flags.
font (wx.Font) –
flags (int) –
bool
GetFontEncoding
(self)¶Returns the font encoding.
GetFontFaceName
(self)¶Returns the font face name.
string
GetFontFamily
(self)¶Returns the font family.
GetFontSize
(self)¶Returns the font size in points.
int
GetFontStyle
(self)¶Returns the font style.
GetFontUnderlined
(self)¶Returns True
if the font is underlined.
bool
GetFontWeight
(self)¶Returns the font weight.
GetLeftIndent
(self)¶Returns the left indent in tenths of a millimetre.
long
GetLeftSubIndent
(self)¶Returns the left sub-indent in tenths of a millimetre.
long
GetLineSpacing
(self)¶Returns the line spacing value, one of wx.TextAttrLineSpacing values.
int
GetListStyleName
(self)¶Returns the name of the list style.
string
GetOutlineLevel
(self)¶Returns the outline level.
int
GetParagraphSpacingAfter
(self)¶Returns the space in tenths of a millimeter after the paragraph.
int
GetParagraphSpacingBefore
(self)¶Returns the space in tenths of a millimeter before the paragraph.
int
GetParagraphStyleName
(self)¶Returns the name of the paragraph style.
string
GetRightIndent
(self)¶Returns the right indent in tenths of a millimeter.
long
GetTabs
(self)¶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.
list of integers
GetTextEffectFlags
(self)¶Returns the text effect bits of interest.
See SetFlags
for further information.
int
GetTextEffects
(self)¶Returns the text effects, a bit list of styles.
See SetTextEffects
for details.
int
GetURL
(self)¶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.
string
HasAlignment
(self)¶Returns True
if the attribute object specifies alignment.
bool
HasBackgroundColour
(self)¶Returns True
if the attribute object specifies a background colour.
bool
HasBulletName
(self)¶Returns True
if the attribute object specifies a standard bullet name.
bool
HasBulletNumber
(self)¶Returns True
if the attribute object specifies a bullet number.
bool
HasBulletStyle
(self)¶Returns True
if the attribute object specifies a bullet style.
bool
HasBulletText
(self)¶Returns True
if the attribute object specifies bullet text (usually specifying a symbol).
bool
HasCharacterStyleName
(self)¶Returns True
if the attribute object specifies a character style name.
bool
HasFlag
(self, flag)¶Returns True
if the flag is present in the attribute object’s flag bitlist.
flag (long) –
bool
HasFont
(self)¶Returns True
if the attribute object specifies any font attributes.
bool
HasFontEncoding
(self)¶Returns True
if the attribute object specifies an encoding.
bool
HasFontFaceName
(self)¶Returns True
if the attribute object specifies a font face name.
bool
HasFontFamily
(self)¶Returns True
if the attribute object specifies a font family.
bool
HasFontItalic
(self)¶Returns True
if the attribute object specifies italic style.
bool
HasFontPixelSize
(self)¶Returns True
if the attribute object specifies a font pixel size.
bool
HasFontPointSize
(self)¶Returns True
if the attribute object specifies a font point size.
bool
HasFontSize
(self)¶Returns True
if the attribute object specifies a font point or pixel size.
bool
HasFontUnderlined
(self)¶Returns True
if the attribute object specifies either underlining or no underlining.
bool
HasFontWeight
(self)¶Returns True
if the attribute object specifies font weight (bold, light or normal).
bool
HasLeftIndent
(self)¶Returns True
if the attribute object specifies a left indent.
bool
HasLineSpacing
(self)¶Returns True
if the attribute object specifies line spacing.
bool
HasListStyleName
(self)¶Returns True
if the attribute object specifies a list style name.
bool
HasOutlineLevel
(self)¶Returns True
if the attribute object specifies an outline level.
bool
HasPageBreak
(self)¶Returns True
if the attribute object specifies a page break before this paragraph.
bool
HasParagraphSpacingAfter
(self)¶Returns True
if the attribute object specifies spacing after a paragraph.
bool
HasParagraphSpacingBefore
(self)¶Returns True
if the attribute object specifies spacing before a paragraph.
bool
HasParagraphStyleName
(self)¶Returns True
if the attribute object specifies a paragraph style name.
bool
HasRightIndent
(self)¶Returns True
if the attribute object specifies a right indent.
bool
HasTabs
(self)¶Returns True
if the attribute object specifies tab stops.
bool
HasTextColour
(self)¶Returns True
if the attribute object specifies a text foreground colour.
bool
HasTextEffects
(self)¶Returns True
if the attribute object specifies text effects.
bool
HasURL
(self)¶Returns True
if the attribute object specifies a URL.
bool
IsCharacterStyle
(self)¶Returns True
if the object represents a character style, that is, the flags specify a font or a text background or foreground colour.
bool
IsDefault
(self)¶Returns False
if we have any attributes set, True
otherwise.
bool
IsParagraphStyle
(self)¶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, *args, **kw)¶Merge (self, overlay)
Copies all defined/valid properties from overlay to current object.
overlay (wx.TextAttr) –
Merge (base, overlay)
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) –
SetAlignment
(self, alignment)¶Sets the paragraph alignment.
See wx.TextAttrAlignment enumeration values.
Of these, wx.TEXT_ALIGNMENT_JUSTIFIED
is unimplemented. In future justification may be supported when printing or previewing, only.
alignment (TextAttrAlignment) –
SetBulletFont
(self, font)¶Sets the name of the font associated with the bullet symbol.
Only valid for attributes with TEXT_ATTR_BULLET_SYMBOL
.
font (string) –
SetBulletName
(self, name)¶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) –
SetBulletNumber
(self, n)¶Sets the bullet number.
n (int) –
SetBulletStyle
(self, style)¶Sets the bullet style.
The wx.TextAttrBulletStyle enumeration values are all supported, except for wx.TEXT_ATTR_BULLET_STYLE_BITMAP
.
style (int) –
SetBulletText
(self, text)¶Sets the bullet text, which could be a symbol, or (for example) cached outline text.
text (string) –
SetCharacterStyleName
(self, name)¶Sets the character style name.
name (string) –
SetFlags
(self, flags)¶Sets the flags determining which styles are being specified.
The wx.TextAttrFlags values can be passed in a bitlist.
flags (long) –
SetFont
(self, font, flags=TEXT_ATTR_FONT & ~TEXT_ATTR_FONT_PIXEL_SIZE)¶Sets the attributes for the given font.
Note that wx.TextAttr does not store an actual wx.Font object.
font (wx.Font) –
flags (int) –
SetFontEncoding
(self, encoding)¶Sets the font encoding.
encoding (FontEncoding) –
SetFontFaceName
(self, faceName)¶Sets the font face name.
faceName (string) –
SetFontFamily
(self, family)¶Sets the font family.
family (FontFamily) –
SetFontPixelSize
(self, pixelSize)¶Sets the font size in pixels.
pixelSize (int) –
SetFontPointSize
(self, pointSize)¶Sets the font size in points.
pointSize (int) –
SetFontSize
(self, pointSize)¶Sets the font size in points.
pointSize (int) –
SetFontStyle
(self, fontStyle)¶Sets the font style (normal, italic or slanted).
fontStyle (FontStyle) –
SetFontUnderlined
(self, underlined)¶Sets the font underlining.
underlined (bool) –
SetFontWeight
(self, fontWeight)¶Sets the font weight.
fontWeight (FontWeight) –
SetLeftIndent
(self, indent, subIndent=0)¶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.
indent (int) –
subIndent (int) –
SetLineSpacing
(self, spacing)¶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.
spacing (int) –
SetListStyleName
(self, name)¶Sets the list style name.
name (string) –
SetOutlineLevel
(self, level)¶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) –
SetPageBreak
(self, pageBreak=True)¶Specifies a page break before this paragraph.
pageBreak (bool) –
SetParagraphSpacingAfter
(self, spacing)¶Sets the spacing after a paragraph, in tenths of a millimetre.
spacing (int) –
SetParagraphSpacingBefore
(self, spacing)¶Sets the spacing before a paragraph, in tenths of a millimetre.
spacing (int) –
SetParagraphStyleName
(self, name)¶Sets the name of the paragraph style.
name (string) –
SetRightIndent
(self, indent)¶Sets the right indent in tenths of a millimetre.
indent (int) –
SetTabs
(self, tabs)¶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.
tabs (list of integers) –
SetTextEffectFlags
(self, flags)¶Sets the text effect bits of interest.
You should also pass wx.TEXT_ATTR_EFFECTS
to SetFlags
. See SetFlags
for further information.
flags (int) –
SetTextEffects
(self, effects)¶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) –
SetURL
(self, url)¶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) –
Alignment
¶See GetAlignment
and SetAlignment
BackgroundColour
¶BulletFont
¶See GetBulletFont
and SetBulletFont
BulletName
¶See GetBulletName
and SetBulletName
BulletNumber
¶See GetBulletNumber
and SetBulletNumber
BulletStyle
¶See GetBulletStyle
and SetBulletStyle
BulletText
¶See GetBulletText
and SetBulletText
CharacterStyleName
¶FontEncoding
¶See GetFontEncoding
and SetFontEncoding
FontFaceName
¶See GetFontFaceName
and SetFontFaceName
FontFamily
¶See GetFontFamily
and SetFontFamily
FontSize
¶See GetFontSize
and SetFontSize
FontStyle
¶See GetFontStyle
and SetFontStyle
FontUnderlined
¶See GetFontUnderlined
and SetFontUnderlined
FontWeight
¶See GetFontWeight
and SetFontWeight
LeftIndent
¶See GetLeftIndent
and SetLeftIndent
LeftSubIndent
¶See GetLeftSubIndent
LineSpacing
¶See GetLineSpacing
and SetLineSpacing
ListStyleName
¶See GetListStyleName
and SetListStyleName
OutlineLevel
¶See GetOutlineLevel
and SetOutlineLevel
ParagraphSpacingAfter
¶ParagraphSpacingBefore
¶ParagraphStyleName
¶RightIndent
¶See GetRightIndent
and SetRightIndent
TextColour
¶See GetTextColour
and SetTextColour
TextEffectFlags
¶See GetTextEffectFlags
and SetTextEffectFlags
TextEffects
¶See GetTextEffects
and SetTextEffects