def setPosition(self, position): Container.setPosition(self, position) x, y = position self.cursor.setPosition(self._cursorPosition()) self.label.setPosition((x + 3, y)) self.label.rect.bottom = self.rect.bottom - 2
def __init__(self, text, width, height, background=(255, 255, 255), *args, **kwargs): kwargs['border'] = (1, (0, 0, 0)) Container.__init__(self, width, height, *args, **kwargs) self.cursorPosition = 0 self.text = "" self.textDisplayedBeginIndex = 0 self.cursor = Image('textcursor', root=self.root) self.add(self.cursor) self.label = Label('', root=self.root, fontSize=30) self.add(self.label)
def update(self, *args): Container.update(self, *args) self.cursor.setPosition(self._cursorPosition()) self.label.setText(self._viewableText()) self.label.changeLayer(self.layer + 1) self.cursor.changeLayer(self.layer + 2)