def __init__(self, position, width, height): """ Creates a new Panel with no children at the given position relative to its parent, and with the given width and height. @type position: C{(int, int)} @param position: Position of the Widget in pixels, relative to its parent. @type width: C{int} @param width: Width of the Widget. @type height: C{int} @param height: Height of the Widget. """ Widget.__init__(self, position, width, height) self._children = []
def __init__(self, position, fontPath, fontSize, text, fontColor=None, fontBGColor=None): """ Creates a new Text UI widget at the given position, and with the given text attributes. @type position: C{(int, int)} @param position: Position of the Widget in pixels, relative to its parent. @type fontPath: C{str} @param fontPath: File path to the chosen font. If it is a system font, only the name is needed, such as C{'Courier New'}, otherwise it should be an absolute path. @type fontSize: C{int} @param fontSize: Size of the font. @type text: C{str} @param text: Text that should be displayed. Newline characters will be ignored. @type fontColor: U{C{pygame.color}<http://www.pygame.org/docs/ref/color.html>} @param fontColor: The color of the font. If C{None} the font will be black. @type fontBGColor: U{C{pygame.color}<http://www.pygame.org/docs/ref/color.html>} @param fontBGColor: The background color of the text. If C{None} it will be clear. """ Widget.__init__(self, position, 1, 1) self._fontPath = fontPath self.Text = text self._fontSize = fontSize if not os.path.exists(fontPath): self._font = pygame.font.SysFont(fontPath, fontSize) else: fontPath = os.path.normpath(os.path.realpath(fontPath)) self._font = pygame.font.Font(fontPath, fontSize) # reset font path to relative for output self._fontPath = fontPath.lstrip(os.path.normpath(os.path.realpath(Constants.GameConstants.BASE_PATH))) if not fontColor: self._fontColor = pygame.Color(0, 0, 0) else: self._fontColor = fontColor self._fontBGColor = fontBGColor self.__build_surface__()
def __init__(self, position, width, height, color): """ Creates a new Box UI widget at the position with the given dimensions and color. @type position: C{(int, int)} @param position: Position of the Widget in pixels, relative to its parent. @type width: C{int} @param width: Width of the Widget. @type height: C{int} @param height: Height of the Widget. @type color: U{C{pygame.color}<http://www.pygame.org/docs/ref/color.html>} @param color: The color of the Box. """ Widget.__init__(self, position, width, height) self._color = color self._image = pygame.Surface((self._rect.width, self._rect.height), pygame.SRCALPHA) self._image.convert_alpha() self._image.fill(self.Color)