How to use the socli.socli.UnicodeText function in socli

To help you get started, we’ve selected a few socli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gautamkrishnar / socli / socli / socli.py View on Github external
self.url = question_url
        self.answer_text = AnswerText(answers)
        self.screenHeight, screenWidth = subprocess.check_output(['stty', 'size']).split()
        self.question_text = urwid.BoxAdapter(QuestionDescription(question_desc), int(max(1, (int(self.screenHeight) - 9) / 2)))
        answer_frame = urwid.Frame(
            header= urwid.Pile( [
                header_for_display,
                QuestionTitle(question_title),
                self.question_text,
                QuestionStats(question_stats),
                urwid.Divider('-')
            ]),
            body=self.answer_text,
            footer= urwid.Pile([
                QuestionURL(question_url),
                UnicodeText(u'p: previous answer, n: next answer, o: open in browser, b: back')
            ])
        )
        return answer_frame
github gautamkrishnar / socli / socli / socli.py View on Github external
"""
        self.content =  self.description.strip("\n").split("\n")
        self._w = ScrollableTextBox(self.content)

    def __len__(self):
        """ return number of rows in this widget """
        return len(self.content)

class QuestionStats(UnicodeText):
    """ Stats of the question,"""

    def __init__(self, stats):
        text = ["\n", ('metadata', stats)]
        UnicodeText.__init__(self, text)

class QuestionURL(UnicodeText):
    """ url of the question """

    def __init__(self, url):
        text = ["\n", ('heading', 'Question URL: '), url]
        UnicodeText.__init__(self, text)

def format_str(str, color):
    return "{0}{1}{2}".format(color, str, colorama.Style.RESET_ALL)


def print_header(str):
    print(format_str(str, colorama.Fore.MAGENTA))


def print_blue(str):
    print(format_str(str, colorama.Fore.BLUE))
github gautamkrishnar / socli / socli / socli.py View on Github external
self.set_description()

    def set_description(self):
        """
        We must use a box adapter to get the text to scroll when this widget is already in
        a Pile from the main question page. Scrolling is necessary for long questions which are longer
        than the length of the terminal.
        """
        self.content =  self.description.strip("\n").split("\n")
        self._w = ScrollableTextBox(self.content)

    def __len__(self):
        """ return number of rows in this widget """
        return len(self.content)

class QuestionStats(UnicodeText):
    """ Stats of the question,"""

    def __init__(self, stats):
        text = ["\n", ('metadata', stats)]
        UnicodeText.__init__(self, text)

class QuestionURL(UnicodeText):
    """ url of the question """

    def __init__(self, url):
        text = ["\n", ('heading', 'Question URL: '), url]
        UnicodeText.__init__(self, text)

def format_str(str, color):
    return "{0}{1}{2}".format(color, str, colorama.Style.RESET_ALL)
github gautamkrishnar / socli / socli / socli.py View on Github external
def __init__(self, questions):
            self.questions = questions
            self.cachedQuestions = [None for _ in range(10)]
            widgets = [self.display_text(i, q) for i, q in enumerate(questions)]
            self.questions_box = ScrollableTextBox(widgets)
            self.header = UnicodeText(('less-important', 'Select a question below:\n'))
            self.footerText = '0-' + str(len(self.questions) - 1) + ': select a question, any other key: exit.'
            self.errorText = UnicodeText.to_unicode('Question numbers range from 0-' +
                                                    str(len(self.questions) - 1) +
                                                    ". Please select a valid question number.")
            self.footer = UnicodeText(self.footerText)
            self.footerText = UnicodeText.to_unicode(self.footerText)
            frame = urwid.Frame(header=self.header,
                                body=urwid.Filler(self.questions_box, height=('relative', 100), valign='top'),
                                footer=self.footer)
            urwid.WidgetWrap.__init__(self, frame)
github gautamkrishnar / socli / socli / socli.py View on Github external
def __init__(self, questions):
            self.questions = questions
            self.cachedQuestions = [None for _ in range(10)]
            widgets = [self.display_text(i, q) for i, q in enumerate(questions)]
            self.questions_box = ScrollableTextBox(widgets)
            self.header = UnicodeText(('less-important', 'Select a question below:\n'))
            self.footerText = '0-' + str(len(self.questions) - 1) + ': select a question, any other key: exit.'
            self.errorText = UnicodeText.to_unicode('Question numbers range from 0-' +
                                                    str(len(self.questions) - 1) +
                                                    ". Please select a valid question number.")
            self.footer = UnicodeText(self.footerText)
            self.footerText = UnicodeText.to_unicode(self.footerText)
            frame = urwid.Frame(header=self.header,
                                body=urwid.Filler(self.questions_box, height=('relative', 100), valign='top'),
                                footer=self.footer)
            urwid.WidgetWrap.__init__(self, frame)