DirectLabel.py 1.6 KB

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