def __init__(self, text, tail=None, uni=False): """ :param text: The text to be put into a speech bubble. :param tail: Where to put the bubble callout tail, specifying "L" or "R" for left or right tails. Can be None for no tail. """ super(SpeechBubble, self).__init__() max_len = max([wcswidth(x) for x in text.split("\n")]) if uni: bubble = "╭─" + "─" * max_len + "─╮\n" for line in text.split("\n"): filler = " " * (max_len - len(line)) bubble += "│ " + line + filler + " │\n" bubble += "╰─" + "─" * max_len + "─╯" else: bubble = ".-" + "-" * max_len + "-.\n" for line in text.split("\n"): filler = " " * (max_len - len(line)) bubble += "| " + line + filler + " |\n" bubble += "`-" + "-" * max_len + "-`" if tail == "L": bubble += "\n" bubble += " )/ \n" bubble += "-\"`\n" elif tail == "R": bubble += "\n" bubble += (" " * max_len) + "\\( \n" bubble += (" " * max_len) + " `\"-\n" self._images = [bubble]
def __init__(self, text, tail=None, uni=False): """ :param text: The text to be put into a speech bubble. :param tail: Where to put the bubble callout tail, specifying "L" or "R" for left or right tails. Can be None for no tail. """ super(SpeechBubble, self).__init__() max_len = max([wcswidth(x) for x in text.split("\n")]) if uni: bubble = "╭─" + "─" * max_len + "─╮\n" for line in text.split("\n"): bubble += "│ " + line + " │\n" bubble += "╰─" + "─" * max_len + "─╯\n" else: bubble = ".-" + "-" * max_len + "-.\n" for line in text.split("\n"): bubble += "| " + line + " |\n" bubble += "`-" + "-" * max_len + "-`\n" if tail == "L": bubble += " )/ \n" bubble += "-\"`\n" elif tail == "R": bubble += (" " * max_len) + "\\( \n" bubble += (" " * max_len) + " `\"-\n" self._images = [bubble]
def max_width(self): """ :return: The max width of the rendered text (across all images if an animated renderer). """ if len(self._plain_images) <= 0: self._convert_images() if self._max_width == 0: for image in self._plain_images: new_max = max([wcswidth(x) for x in image]) self._max_width = max(new_max, self._max_width) return self._max_width
def max_width(self): """ :return: The max width of the rendered text (across all images if an animated renderer). """ if len(self._plain_images) <= 0: self._convert_images() if self._max_width == 0: for image in self._plain_images: new_max = max([wcswidth(x) for x in image]) self._max_width = max(new_max, self._max_width) return self._max_width