text_item.py 834 B

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. #local import
  3. from UI.constants import Width,Height,ICON_TYPES
  4. from UI.icon_item import IconItem
  5. from UI.util_funcs import midRect
  6. class TextItem(IconItem):
  7. _PosX = 0
  8. _PosY = 0
  9. _Width = 0
  10. _Height = 0
  11. _Str = ""
  12. _Color = (83,83,83)
  13. _FontObj = None
  14. _Bold = False
  15. _MyType = ICON_TYPES["LETTER"]
  16. _Parent = None
  17. def Draw(self):
  18. self._FontObj.set_bold(self._Bold)
  19. my_text = self._FontObj.render(self._Str,True,self._Color)
  20. if my_text.get_width() != self._Width:
  21. self._Width = my_text.get_width()
  22. if my_text.get_height() != self._Height:
  23. self._Height = my_text.get_height()
  24. self._Parent._CanvasHWND.blit(my_text, \
  25. midRect(self._PosX,self._PosY,self._Width,self._Height,Width,Height))