def draw(self, width, height): if self.textline: self.removeChild(self.textline) tb = TextBlock() tb.content = TextElement(self.text, self.format) self.textline = tb.createTextLine(None, width) self.addChild(self.textline)
def label_node(self, node): font = FontDescription("Arial") format = ElementFormat(font) format.fontSize = 14 el = TextElement(node.label or node.name, format) block = TextBlock() block.content = el tl = block.createTextLine(None, node.width*36) pos = node.label_pos if not pos: pos = node tl.x = int(pos.x-tl.width/2) tl.y = int(pos.y+tl.height/2) self.sprite.addChild(tl)