Package peppy :: Package editra :: Module ed_style :: Class StyleItem
[frames] | no frames]

Class StyleItem

object --+
         |
        StyleItem

A storage class for holding styling information


To Do: The extra Attributes should be saved as a separate attribute in the StyleItem. This currenlty causes problems when customizing values in the StyleEditor Changing this is fairly easy in this class but it will require changes to the StyleMgr and Editor as well.

Instance Methods
 
GetBack(self)
Returns the value of the back attribute
 
GetFace(self)
Returns the value of the face attribute
 
GetFore(self)
Returns the value of the fore attribute
 
GetSize(self)
Returns the value of the size attribute as a string
 
SetAttrFromStr(self, style_str)
Takes style string and sets the objects attributes by parsing the string for the values.
 
SetBack(self, back, ex=u'')
Sets the Background Value
 
SetExAttr(self, ex_attr, add=True)
Adds an extra text attribute to a StyleItem.
 
SetFace(self, face, ex=u'')
Sets the Face Value
 
SetFore(self, fore, ex=u'')
Sets the Foreground Value
 
SetNamedAttr(self, attr, value)
Sets a StyleItem attribute by named string.
 
SetSize(self, size, ex=u'')
Sets the Font Size Value
bool
__eq__(self, si2)
Defines the == operator for the StyleItem Class
 
__init__(self, fore=u'', back=u'', face=u'', size=u'')
Initiliazes the Style Object.
 
__str__(self)
Converts StyleItem to a string

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Properties

Inherited from object: __class__

Method Details

GetBack(self)

 

Returns the value of the back attribute

Returns:
style items background attribute

GetFace(self)

 

Returns the value of the face attribute

Returns:
style items font face attribute

GetFore(self)

 

Returns the value of the fore attribute

Returns:
style items foreground attribute

GetSize(self)

 

Returns the value of the size attribute as a string

Returns:
style items font size attribute

SetAttrFromStr(self, style_str)

 

Takes style string and sets the objects attributes by parsing the string for the values. Only sets or overwrites values does not zero out previously set values. Returning True if value(s) are set or false otherwise.

Parameters:
  • style_str (string) - style information string (i.e fore:#888444)

SetBack(self, back, ex=u'')

 

Sets the Background Value

Parameters:
  • back - hex color string
  • ex - extra attribute (i.e bold, italic, underline)

SetExAttr(self, ex_attr, add=True)

 

Adds an extra text attribute to a StyleItem. Currently (bold, eol, italic, underline) are supported. If the optional add value is set to False the attribute will be removed from the StyleItem.

Parameters:
  • ex_attr (string) - extra style attribute (bold, eol, italic, underline)
  • add - Add a style (True) or remove a style (False)

SetFace(self, face, ex=u'')

 

Sets the Face Value

Parameters:
  • back - font name string
  • ex - extra attribute (i.e bold, italic, underline)

SetFore(self, fore, ex=u'')

 

Sets the Foreground Value

Parameters:
  • back - hex color string
  • ex - extra attribute (i.e bold, italic, underline)

SetNamedAttr(self, attr, value)

 

Sets a StyleItem attribute by named string.

Parameters:
  • attr - a particular attribute to set (i.e fore, face, back, size)
  • value - value to set the attribute to contain

Note: This is not intended to be used for setting extra attributes such as bold, eol, ect..

SetSize(self, size, ex=u'')

 

Sets the Font Size Value

Parameters:
  • back (string or int) - font point size
  • ex - extra attribute (i.e bold, italic, underline)

__eq__(self, si2)
(Equality operator)

 

Defines the == operator for the StyleItem Class

Parameters:
  • si2 - style item to compare to
Returns: bool
whether the two items are equal

__init__(self, fore=u'', back=u'', face=u'', size=u'')
(Constructor)

 
Initiliazes the Style Object.

@param fore: Specifies the forground color (hex string)
@param face: Specifies the font face (string face name)
@param back: Specifies the background color (hex string)
@param size: Specifies font point size (int/formatted string)

SPECIFICATION:
  DATA FORMATS:
    #123456       = hex color code
    #123456,bold  = hex color code + extra style
    Monaco        = Font Face Name
    %(primary)s      = Format string to be swapped at runtime
    10            = A font point size
    %(size)s      = Format string to be swapped at runtime

Overrides: object.__init__

__str__(self)
(Informal representation operator)

 

Converts StyleItem to a string

Returns:
string representation of the StyleItem
Overrides: object.__str__