Panda3D
Loading...
Searching...
No Matches
OnscreenText Class Reference
Inheritance diagram for OnscreenText:

Public Member Functions

 __init__ (self, text='', style=Plain, pos=(0, 0), roll=0, scale=None, fg=None, bg=None, shadow=None, shadowOffset=(0.04, 0.04), frame=None, align=None, wordwrap=None, drawOrder=None, decal=0, font=None, parent=None, sort=0, mayChange=True, direction=None)
 
 __setitem__ (self, key, value)
 
 appendText (self, text)
 
 cget (self, option)
 
 cleanup (self)
 
 clearText (self)
 
 configure (self, option=None, **kw)
 
 destroy (self)
 
 freeze (self)
 
 getDecal (self)
 
 getFont (self)
 
 getPos (self)
 
 getRoll (self)
 
 getScale (self)
 
 getText (self)
 
 getTextPos (self)
 
 getTextR (self)
 
 getTextScale (self)
 
 getWordwrap (self)
 
 setAlign (self, align)
 
 setBg (self, bg)
 
 setDecal (self, decal)
 
 setFg (self, fg)
 
 setFont (self, font)
 
 setFrame (self, frame)
 
 setPos (self, x, y)
 
 setRoll (self, roll)
 
 setScale (self, sx, sy=None)
 
 setShadow (self, shadow)
 
 setText (self, text)
 
 setTextPos (self, x, y=None)
 
 setTextR (self, r)
 
 setTextScale (self, sx, sy=None)
 
 setTextX (self, x)
 
 setTextY (self, y)
 
 setWordwrap (self, wordwrap)
 
 setX (self, x)
 
 setY (self, y)
 
 thaw (self)
 
 updateTransformMat (self)
 

Public Attributes

int isClean = 0
 
int mayChange = 1
 
 textNode = textNode
 
bool unicodeText = True
 

Properties

 align = property(__getAlign, setAlign)
 
 bg = property(__getBg, setBg)
 
 decal = property(getDecal, setDecal)
 
 fg = property(__getFg, setFg)
 
 font = property(getFont, setFont)
 
 frame = property(__getFrame, setFrame)
 
 pos = property(getPos)
 
 roll = property(getRoll, setRoll)
 
 scale = property(getScale, setScale)
 
 shadow = property(__getShadow, setShadow)
 
 text = property(getText, setText)
 
 text_pos = property(getTextPos, setTextPos)
 
 text_r = property(getTextR, setTextR)
 
 text_scale = property(getTextScale, setTextScale)
 
 wordwrap = property(getWordwrap, setWordwrap)
 

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
text = '',
style = Plain,
pos = (0, 0),
roll = 0,
scale = None,
fg = None,
bg = None,
shadow = None,
shadowOffset = (0.04, 0.04),
frame = None,
align = None,
wordwrap = None,
drawOrder = None,
decal = 0,
font = None,
parent = None,
sort = 0,
mayChange = True,
direction = None )
Make a text node from string, put it into the 2d sg and set it
up with all the indicated parameters.

Parameters:

  text: the actual text to display.  This may be omitted and
      specified later via setText() if you don't have it
      available, but it is better to specify it up front.

  style: one of the pre-canned style parameters defined at the
      head of this file.  This sets up the default values for
      many of the remaining parameters if they are
      unspecified; however, a parameter may still be specified
      to explicitly set it, overriding the pre-canned style.

  pos: the x, y position of the text on the screen.

  scale: the size of the text.  This may either be a single
      float (and it will usually be a small number like 0.07)
      or it may be a 2-tuple of floats, specifying a different
      x, y scale.

  fg: the (r, g, b, a) foreground color of the text.  This is
      normally a 4-tuple of floats or ints.

  bg: the (r, g, b, a) background color of the text.  If the
      fourth value, a, is nonzero, a card is created to place
      behind the text and set to the given color.

  shadow: the (r, g, b, a) color of the shadow behind the text.
      If the fourth value, a, is nonzero, a little drop shadow
      is created and placed behind the text.

  frame: the (r, g, b, a) color of the frame drawn around the
      text.  If the fourth value, a, is nonzero, a frame is
      created around the text.

  align: one of TextNode.ALeft, TextNode.ARight, or TextNode.ACenter.

  wordwrap: either the width to wordwrap the text at, or None
      to specify no automatic word wrapping.

  drawOrder: the drawing order of this text with respect to
      all other things in the 'fixed' bin within render2d.
      The text will actually use drawOrder through drawOrder +
      2.

  decal: if this is True, the text is decalled onto its
      background card.  Useful when the text will be parented
      into the 3-D scene graph.

  font: the font to use for the text.

  parent: the NodePath to parent the text to initially.

  mayChange: pass true if the text or its properties may need
      to be changed at runtime, false if it is static once
      created (which leads to better memory optimization).

  direction: this can be set to 'ltr' or 'rtl' to override the
      direction of the text.

Member Function Documentation

◆ __setitem__()

__setitem__ ( self,
key,
value )

◆ appendText()

appendText ( self,
text )

◆ cget()

cget ( self,
option )

◆ cleanup()

cleanup ( self)

◆ clearText()

clearText ( self)

◆ configure()

configure ( self,
option = None,
** kw )

◆ destroy()

destroy ( self)

◆ freeze()

freeze ( self)

◆ getDecal()

getDecal ( self)

◆ getFont()

getFont ( self)

◆ getPos()

getPos ( self)
.. deprecated:: 1.11.0
   Use `.getTextPos()` method or `.text_pos` property instead.

◆ getRoll()

getRoll ( self)
.. deprecated:: 1.11.0
   Use ``-getTextR()`` instead (note the negated sign).

◆ getScale()

getScale ( self)
.. deprecated:: 1.11.0
   Use `.getTextScale()` method or `.text_scale` property instead.

◆ getText()

getText ( self)

◆ getTextPos()

getTextPos ( self)
.. versionadded:: 1.10.8

◆ getTextR()

getTextR ( self)

◆ getTextScale()

getTextScale ( self)
.. versionadded:: 1.10.8

◆ getWordwrap()

getWordwrap ( self)

◆ setAlign()

setAlign ( self,
align )

◆ setBg()

setBg ( self,
bg )

◆ setDecal()

setDecal ( self,
decal )

◆ setFg()

setFg ( self,
fg )

◆ setFont()

setFont ( self,
font )

◆ setFrame()

setFrame ( self,
frame )

◆ setPos()

setPos ( self,
x,
y )
setPos(self, float, float)
Position the onscreen text in 2d screen space

.. deprecated:: 1.11.0
   Use `.setTextPos()` method or `.text_pos` property instead.

◆ setRoll()

setRoll ( self,
roll )
setRoll(self, float)
Rotate the onscreen text around the screen's normal.

.. deprecated:: 1.11.0
   Use ``setTextR(-roll)`` instead (note the negated sign).

◆ setScale()

setScale ( self,
sx,
sy = None )
setScale(self, float, float)
Scale the text in 2d space.  You may specify either a single
uniform scale, or two scales, or a tuple of two scales.

.. deprecated:: 1.11.0
   Use `.setTextScale()` method or `.text_scale` property instead.

◆ setShadow()

setShadow ( self,
shadow )

◆ setText()

setText ( self,
text )

◆ setTextPos()

setTextPos ( self,
x,
y = None )
Position the onscreen text in 2d screen space

.. versionadded:: 1.10.8

◆ setTextR()

setTextR ( self,
r )
setTextR(self, float)
Rotates the text around the screen's normal.

.. versionadded:: 1.10.8

◆ setTextScale()

setTextScale ( self,
sx,
sy = None )
setTextScale(self, float, float)
Scale the text in 2d space.  You may specify either a single
uniform scale, or two scales, or a tuple of two scales.

.. versionadded:: 1.10.8

◆ setTextX()

setTextX ( self,
x )
.. versionadded:: 1.10.8

◆ setTextY()

setTextY ( self,
y )
.. versionadded:: 1.10.8

◆ setWordwrap()

setWordwrap ( self,
wordwrap )

◆ setX()

setX ( self,
x )
.. deprecated:: 1.11.0
   Use `.setTextX()` method instead.

◆ setY()

setY ( self,
y )
.. deprecated:: 1.11.0
   Use `.setTextY()` method instead.

◆ thaw()

thaw ( self)

◆ updateTransformMat()

updateTransformMat ( self)

Member Data Documentation

◆ isClean

int isClean = 0

◆ mayChange

int mayChange = 1

◆ textNode

textNode = textNode

◆ unicodeText

bool unicodeText = True

Property Documentation

◆ align

align = property(__getAlign, setAlign)
static

◆ bg

bg = property(__getBg, setBg)
static

◆ decal

decal = property(getDecal, setDecal)
static

◆ fg

fg = property(__getFg, setFg)
static

◆ font

font = property(getFont, setFont)
static

◆ frame

frame = property(__getFrame, setFrame)
static

◆ pos

pos = property(getPos)
static

◆ roll

roll = property(getRoll, setRoll)
static

◆ scale

scale = property(getScale, setScale)
static

◆ shadow

shadow = property(__getShadow, setShadow)
static

◆ text

text = property(getText, setText)
static

◆ text_pos

text_pos = property(getTextPos, setTextPos)
static

◆ text_r

text_r = property(getTextR, setTextR)
static

◆ text_scale

text_scale = property(getTextScale, setTextScale)
static

◆ wordwrap

wordwrap = property(getWordwrap, setWordwrap)
static