wx.TextAttr

Inheritance diagram for wx.TextAttr:



Description

wx.TextAttr represents the character and paragraph attributes, or style, for a range of text in a wx.TextCtrl.

When setting up a wx.TextAttr object, pass a bitlist mask to 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.

Constants

The following values can be passed to SetAlignment to determine paragraph alignment:

  • wx.TEXT_ALIGNMENT_DEFAULT
  • wx.TEXT_ALIGNMENT_LEFT
  • wx.TEXT_ALIGNMENT_CENTRE
  • wx.TEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE
  • wx.TEXT_ALIGNMENT_RIGHT
  • wx.TEXT_ALIGNMENT_JUSTIFIED

These values are passed in a bitlist to SetFlags to determine what attributes will be considered when setting the attributes for a text control:

  • wx.TEXT_ATTR_TEXT_COLOUR = 0x0001
  • wx.TEXT_ATTR_BACKGROUND_COLOUR = 0x0002
  • wx.TEXT_ATTR_FONT_FACE = 0x0004
  • wx.TEXT_ATTR_FONT_SIZE = 0x0008
  • wx.TEXT_ATTR_FONT_WEIGHT = 0x0010
  • wx.TEXT_ATTR_FONT_ITALIC = 0x0020
  • wx.TEXT_ATTR_FONT_UNDERLINE = 0x0040
  • wx.TEXT_ATTR_FONT = wx.TEXT_ATTR_FONT_FACE | wx.TEXT_ATTR_FONT_SIZE | wx.TEXT_ATTR_FONT_WEIGHT | wx.TEXT_ATTR_FONT_ITALIC | wx.TEXT_ATTR_FONT_UNDERLINE
  • wx.TEXT_ATTR_ALIGNMENT = 0x0080
  • wx.TEXT_ATTR_LEFT_INDENT = 0x0100
  • wx.TEXT_ATTR_RIGHT_INDENT = 0x0200
  • wx.TEXT_ATTR_TABS = 0x0400

Class API

Methods

__init__(colText=wx.NullColour, colBack=wx.NullColour, font=wx.NullFont, alignment=wx.TEXT_ALIGNMENT_DEFAULT)

The constructors initialize one or more of the text foreground colour, background colour, font, and alignment.

The values not initialized in the constructor can be set later, otherwise wx.TextCtrl.SetStyle will use the default values for them.

Parameters:


Returns:

wx.TextAttr


Combine(attr, attrDef, text)

Parameters:


Returns:

wx.TextAttr


GetAlignment()

Returns the paragraph alignment.


Returns:

int


GetBackgroundColour()

Return the background colour specified by this attribute.


Returns:

wx.Colour


GetFlags()

Returns a bitlist indicating which attributes will be set.


Returns:

long


GetFont()

Return the text font specified by this attribute.


Returns:

wx.Font


GetLeftIndent()

Returns the left indent in tenths of a millimetre.


Returns:

int


GetLeftSubIndent()

Returns the left sub indent for all lines but the first line in a paragraph in tenths of a millimetre.


Returns:

int


GetRightIndent()

Returns the right indent in tenths of a millimetre.


Returns:

int


GetTabs()

Returns the array of integers representing the tab stops. Each array element specifies the tab stop in tenths of a millimetre.


Returns:

list of integers


GetTextColour()

Return the text colour specified by this attribute.


Returns:

wx.Colour


HasAlignment()

Returns True if this style specifies the text alignment.


Returns:

bool


HasBackgroundColour()

Returns True if this style specifies the background colour to use.


Returns:

bool


HasFlag(flag)

Parameters:

  • flag (long)

Returns:

bool


HasFont()

Returns True if this style specifies the font to use.


Returns:

bool


HasLeftIndent()

Returns True if this style specifies the left indent.


Returns:

bool


HasRightIndent()

Returns True if this style specifies the right indent.


Returns:

bool


HasTabs()

Returns True if this style specifies any tabstobs.


Returns:

bool


HasTextColour()

Returns True if this style specifies the foreground colour to use.


Returns:

bool


Init()
No docstrings available for this method.

IsDefault()

Returns True if this style specifies any non-default attributes.


Returns:

bool


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.

Parameters:


Returns:

wx.TextAttr


SetAlignment(alignment)

Sets the paragraph alignment.

Parameters:

  • alignment (int)

SetBackgroundColour(colour)

Sets the background colour.

Parameters:


SetFlags(flags)

Pass a bitlist indicating which attributes will be set.

Parameters:

  • flags (long)

SetFont(font, font font)

Sets the text font.

Parameters:


SetLeftIndent(indent, subIndent=0)

Sets the left indent in tenths of a millimetre. subIndent sets the indent for all lines but the first line in a paragraph relative to the first line.

Parameters:

  • indent (int)
  • subIndent (int)

SetRightIndent(indent)

Sets the right indent in tenths of a millimetre.

Parameters:

  • indent (int)

SetTabs(tabs)

Sets the array of integers representing the tab stops. Each array element specifies the tab stop in tenths of a millimetre.

Parameters:

  • tabs (list of integers)

SetTextColour(colour)

Sets the text colour.

Parameters:


Properties

Alignment
See GetAlignment and SetAlignment
BackgroundColour
See GetBackgroundColour and SetBackgroundColour
Flags
See GetFlags and SetFlags
Font
See GetFont and SetFont
LeftIndent
See GetLeftIndent and SetLeftIndent
LeftSubIndent
See GetLeftSubIndent
RightIndent
See GetRightIndent and SetRightIndent
Tabs
See GetTabs and SetTabs
TextColour
See GetTextColour and SetTextColour