def __init__(self, parent=None, text=None, image=None, rect=sf.Rectangle()): Widget.__init__(self, parent, rect) Active.__init__(self) if text: self._text = text self._textSelect = text.getCopyWidget() self._textActive = self._textSelect self._currentText = self._text else: self._text = None self._textSelect = None self._textActive = None self._currentText = None if image: self._image = image self._imageSelect = image.getCopyWidget() self._imageActive = self._imageSelect self._currentImage = self._image else: self._image = None self._imageSelect = None self._imageActive = None self._currentImage = None self._useCharacterSize = None self._hasImage = False self._hasLabel = False if image: self._imageSelect.lighten() self._image.canFocus = self._imageSelect.canFocus = False self._image.isStaticToView =\ self._imageSelect.isStaticToView = False self._hasImage = True if text: self._textSelect.lighten() self._text.canFocus = self._textSelect.canFocus = False self._text.isStaticToView =\ self._textSelect.isStaticToView = False self._hasLabel = True if rect != sf.Rectangle(): self.rect = rect elif self._hasImage: self.rect = self._image.rect elif self._hasLabel: self.rect = self._text.rect self.drawWidget(True)
def __init__(self, parent=None, rect=sf.Rectangle(sf.Vector2(0,0), sf.Vector2(30,30))): Widget.__init__(self, parent, rect) Active.__init__(self) self._rectangle = sf.RectangleShape(rect.size) self._line = [sf.VertexArray(sf.PrimitiveType.LINES, 2),\ sf.VertexArray(sf.PrimitiveType.LINES, 2)] self.keepActivation = True self.outlineRectangleColor = sf.Color.WHITE self.outlineRectangleThickness = 2 self.crossColor = sf.Color.BLACK self.rect = rect
def __init__(self, parent=None, radius=10, position = sf.Vector2(0,0), \ bigCircleColor=sf.Color.WHITE, \ smallCircleColor=sf.Color.RED, smallCircleProportion = 0.5,\ origin = Position.Center): Widget.__init__(self, parent, \ sf.Rectangle(position, sf.Vector2(radius, radius)/0.5)) Active.__init__(self) self.keepActivation = True self._bigCircle = sf.CircleShape(radius) self._smallCircle = sf.CircleShape(smallCircleProportion * radius) self._bigCircle.fill_color = bigCircleColor self._smallCircle.fill_color = smallCircleColor self._proportion = smallCircleProportion self.size = sf.Vector2(radius, radius)/0.5 self.pos = position self.posOrigin = origin
def __init__(self, parent=None, rect=sf.Rectangle(),\ alignment = Position.Center, spacing=sf.Vector2(0, 0), \ autoDefineSize = True, select=False, active=False, \ alwaysUpdateSelection=True, alwaysUpdateActivation=True, \ permanentSelection=False, permanentActivation=False, \ changeRight = sf.Keyboard.RIGHT, changeLeft = sf.Keyboard.LEFT,\ changeTop = sf.Keyboard.UP, changeBottom = sf.Keyboard.DOWN): Layout.__init__(self, parent, rect, alignment, spacing, autoDefineSize) Active.__init__(self, select, active, alwaysUpdateSelection,\ alwaysUpdateActivation, permanentSelection, permanentActivation) self.canFocus=False self.changeLeft = changeLeft self.changeRight = changeRight self.changeTop = changeTop self.changeBottom = changeBottom self._howActiveKeyboard = [self.changeLeft, self.changeRight, self.changeTop, self.changeBottom] self._currentSelect = None
def __init__(self, parent=None, rect = sf.Rectangle(sf.Vector2(), sf.Vector2(20, 5)), \ defaultText=None, defaultBackground=None, \ defaultForground=None, maxSizeX = sf.Vector2(-1,-1),\ spacing = 0, style=Style.MultiLines, percentage=0.9): Widget.__init__(self, parent, rect) Active.__init__(self) self._maxSize = maxSize self._minSize = rect.size if style == Style.MultiLines and not defaultText: defaultText = TextArray if not defaultBackground: self._background=Image(self, sf.Image(20, 20, sf.Color.MAGENTA)) else: self._background=defaultBackground if not defaultForground: self._forground=Button(self, None, Image(None, sf.Image(20, 20,\ sf.Color.MAGENTA))) else: self._forground = defaultForground self._text = defaultText self._spacing = spacing self._cursor = sf.VertexArray(sf.PrimitiveType.LINES, 2) self._style = style self._percentage = percentage self.keepActivation=True self._howActiveKeyboard=[None, sf.Keyboard.LEFT, sf.Keyboard.RIGHT, \ sf.Keyboard.TOP, sf.Keyboard.DOWN, sf.Keyboard.ESCAPE] self._howActiveMouse=[sf.Mouse.LEFT] self._background.rect = self.rect self._forground.origin = Position.CENTER self._forground.rect = sf.Rectangle(self.pos + self.size/2, \ percentage*self.size) self._background.canFocus = False