DirectLabel.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """Undocumented Module"""
  2. __all__ = ['DirectLabel']
  3. from panda3d.core import *
  4. from .DirectFrame import *
  5. class DirectLabel(DirectFrame):
  6. """
  7. DirectLabel(parent) - Create a DirectGuiWidget which has multiple
  8. states. User explicitly chooses a state to display
  9. """
  10. def __init__(self, parent = None, **kw):
  11. # Inherits from DirectFrame
  12. # A Direct Frame can have:
  13. # - A background texture (pass in path to image, or Texture Card)
  14. # - A midground geometry item (pass in geometry)
  15. # - A foreground text Node (pass in text string or Onscreen Text)
  16. # For a direct label:
  17. # Each label has 1 or more states
  18. # The same image/geom/text can be used for all states or each
  19. # state can have a different text/geom/image
  20. # State transitions happen under user control
  21. optiondefs = (
  22. # Define type of DirectGuiWidget
  23. ('pgFunc', PGItem, None),
  24. ('numStates', 1, None),
  25. ('state', self.inactiveInitState, None),
  26. ('activeState', 0, self.setActiveState),
  27. )
  28. # Merge keyword options with default options
  29. self.defineoptions(kw, optiondefs)
  30. # Initialize superclasses
  31. DirectFrame.__init__(self, parent)
  32. # Call option initialization functions
  33. self.initialiseoptions(DirectLabel)
  34. def setActiveState(self):
  35. """ setActiveState - change label to specifed state """
  36. self.guiItem.setState(self['activeState'])