def add_property(self, name, value):
# get filler space between name and value
spaces = ''
i = self.label_width - len(name)
while i > 0:
spaces += ' '
i -= 1
text = colored(u'\u2502 ', self.border_color)
text += colored(name + ':', self.label_color)
text += spaces
text += colored(value, self.text_color)
# add remaining spaces and end line
spaces = ''
i = self.width - len(value) - self.label_width - 4
while i > 0:
spaces += ' '
i -= 1
text += spaces
text += colored(u'\u2502', self.border_color)
self.text.append(text)
# resizes width of labels for property entries
评论列表
文章目录