cocos.text module¶
Text support
CocosNodes subclasses supporting text. They use a suitable pyglet text object to do the work. Functionality other that the one common to all cococsnodes, except ‘opacity’, is provided by the member ‘element’ , which is the underlying pyglet object.
-
class
HTMLLabel(text=u'', position=(0, 0), **kwargs)¶ Bases:
cocos.text.TextElementHTML formatted text label (supports a subset of HTML 4.01)
Functionality other that the one common to all cococsnodes, except ‘opacity’, is provided by the member ‘element’ , which is the underlying pyglet object. The undelying pyglet object is pyglet.text.HTMLLabel.
- For pyglet 1.1.4 the available init keyword arguments are
- location: Location object for loading images referred to in the document. By default, the working directory is used.
- width: Width of the label in pixels, or None
- height: Height of the label in pixels, or None
- anchor_x: “left”, “center” or “right”.
- anchor_y: one of “bottom”, “baseline”, “center” or “top”.
- multiline : bool
- dpi : float, defaults to 96
-
class
Label(text=u'', position=(0, 0), **kwargs)¶ Bases:
cocos.text.TextElementPlain text support
Functionality other that the one common to all cococsnodes, except ‘opacity’, is provided by the member ‘element’ , which is the underlying pyglet object. The undelying pyglet object is pyglet.text.Label
- For pyglet 1.1.4 the available init keyword arguments are
- font_name: Font family name(s); the first matching name is used
- font_size: Font size, in points
- bold: bool
- italic: bool
- color: (int, int, int, int) Font colour, as RGBA
- width: Width of the label in pixels, or None
- height: Height of the label in pixels, or None
- anchor_x: one of “left”, “center” or “right”
- anchor_y : one of “bottom”, “baseline”, “center” or “top”
- halign : applies when width is supplied. One of “left”, “center” or “right”.
- multiline: bool
- dpi: Resolution of the fonts in this layout. Defaults to 96.
-
class
PygletRichLabel(text=u'', font_name=None, font_size=None, bold=False, italic=False, color=None, x=0, y=0, width=None, height=None, anchor_x=u'left', anchor_y=u'baseline', halign=u'left', multiline=False, dpi=None, batch=None, group=None)¶ Bases:
pyglet.text.DocumentLabelThis is not a CocosNode - let instantiation be handled by RichLabel
Helper class for RichLabel
-
class
RichLabel(text=u'', position=(0, 0), **kwargs)¶ Bases:
cocos.text.TextElementdisplays pyglet attributed (rich) text
The undelying pyglet object is a custom, cocos provided PygletRichLabel element, subclass of pyglet.text.DocumentLabel.
- For pyglet 1.1.4 the available init keyword arguments are
- font_name: Font family name(s); first matching is used
- font_size: Font size, in points.
- bold: bool
- italic: bool
- color : (int, int, int, int) or None
- width: Width of the label in pixels, or None
- height: Height of the label in pixels, or None
- anchor_x: “left”, “center” or “right”
- anchor_y: one of “bottom”, “baseline”, “center” or “top”
- halign : only when a width is supplied. One of “left”, “center”, “right”.
- multiline : bool
- dpi : Resolution of the fonts in this layout. Defaults to 96.
-
klass¶ alias of
PygletRichLabel
-
class
TextElement(text=u'', position=(0, 0), **kwargs)¶ Bases:
cocos.cocosnode.CocosNodeBase class for all cocos text
Provides the CocosNode interfase and a pyglet Batch to store parts Functionality other that the one common to all cococsnodes, except ‘opacity’, is provided by the member ‘element’ , which is the underlying pyglet object.
-
create_element()¶
-
draw()¶
-
opacity¶
-