def layout(self): Viewer.layout(self) # lays out graphics self._button.update(self.x, self.y, self.width, self.height) # centers the label on the middle of the button x, y, width, height = self._button.get_content_region() font = self._label.document.get_font() self._label.x = x + width/2 - self._label.content_width/2 self._label.y = y + height/2 - font.ascent/2 - font.descent self._label.update()
def layout(self): Viewer.layout(self) self._field.update(self.x, self.y, self.width, self.height) x, y, width, height = self._field.get_content_region() if self.is_focus(): self._text_layout.begin_update() self._text_layout.x = self.x + self._padding self._text_layout.y = self.y - self._padding self._text_layout.end_update() else: # Adjust the text for font's descent descent = self._document.get_font().descent self._label.begin_update() self._label.x = self.x + self._padding self._label.y = self.y + self._padding - descent self._label.width = width - self._padding * 2 self._label.end_update()