Python urwid 模块,BoxAdapter() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用urwid.BoxAdapter()

项目:mongoaudit    作者:Exploit-install    | 项目源码 | 文件源码
def __init__(self, title, cred, tests, data):
        self.app = None
        self.tester = data["tester"]
        urn = cred["nodelist"][0][0] + ":" + str(cred["nodelist"][0][1]) + (
            "/" + (cred["database"]) if bool(cred["database"]) else "")

        self.data = {"title": title, "callback": data["callback"],
                     "urn": urn, "num_tests": len(tests)}

        self.progress_text = urwid.Text(
            ('progress', '0/' + str(self.data["num_tests"])))
        running_display = urwid.Columns(
            [(14, urwid.Text(('text', 'Running test'))), self.progress_text])
        self.progress_bar = CustomProgressBar(
            'progress', 'remaining', 0, self.data["num_tests"])
        self.text_running = urwid.Text(('text', ''))
        box = urwid.BoxAdapter(urwid.Filler(
            self.text_running, valign='top'), 2)
        pile = urwid.Pile([running_display, self.progress_bar, DIV, box])
        urwid.WidgetWrap.__init__(self, pile)
项目:mongoaudit    作者:stampery    | 项目源码 | 文件源码
def __init__(self, title, cred, tests, data):
        self.app = None
        self.tester = data["tester"]
        urn = cred["nodelist"][0][0] + ":" + str(cred["nodelist"][0][1]) + (
            "/" + (cred["database"]) if bool(cred["database"]) else "")

        self.data = {"title": title, "callback": data["callback"],
                     "urn": urn, "num_tests": len(tests)}

        self.progress_text = urwid.Text(
            ('progress', '0/' + str(self.data["num_tests"])))
        running_display = urwid.Columns(
            [(14, urwid.Text(('text', 'Running test'))), self.progress_text])
        self.progress_bar = CustomProgressBar(
            'progress', 'remaining', 0, self.data["num_tests"])
        self.text_running = urwid.Text(('text', ''))
        box = urwid.BoxAdapter(urwid.Filler(
            self.text_running, valign='top'), 2)
        pile = urwid.Pile([running_display, self.progress_bar, DIV, box])
        urwid.WidgetWrap.__init__(self, pile)
项目:mongoaudit    作者:Exploit-install    | 项目源码 | 文件源码
def __init__(self, result):
        self.result = result
        self.total = len(result)
        self.update_view('next_callback')

        walker = urwid.SimpleListWalker([urwid.Padding(self.top_columns, left=3, right=3),
                                         self.test_result])

        adapter = urwid.BoxAdapter(urwid.ListBox(walker), height=14)

        urwid.WidgetWrap.__init__(self, adapter)
项目:socli    作者:gautamkrishnar    | 项目源码 | 文件源码
def makeFrame(self, data):
        """
        Returns a new frame that is formatted correctly with respect to the window's dimensions.
        :param data: tuple of (answers, question_title, question_desc, question_stats, question_url)
        :return: a new urwid.Frame object
        """
        answers, question_title, question_desc, question_stats, question_url = data
        self.data = data
        self.question_desc = question_desc
        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'\u2191: previous answer, \u2193: next answer, o: open in browser, \u2190: back')
            ])
        )
        return answer_frame
项目:socli    作者:gautamkrishnar    | 项目源码 | 文件源码
def __init__(self, title):
        text = ["Question: ", ('title', title), "\n"]
        UnicodeText.__init__(self, text)

#Must convert to BoxAdapter object if used as a flow widget.
项目:mongoaudit    作者:stampery    | 项目源码 | 文件源码
def __init__(self, result):
        self.result = result
        self.total = len(result)
        self.update_view('next_callback')

        walker = urwid.SimpleListWalker([urwid.Padding(self.top_columns, left=3, right=3),
                                         self.test_result])

        adapter = urwid.BoxAdapter(urwid.ListBox(walker), height=14)

        urwid.WidgetWrap.__init__(self, adapter)
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def setup_view(self):
        fonts = urwid.get_all_fonts()
        # setup mode radio buttons
        self.font_buttons = []
        group = []
        utf8 = urwid.get_encoding_mode() == "utf8"
        for name, fontcls in fonts:
            font = fontcls()
            if font.utf8_required and not utf8:
                rb = self.create_disabled_radio_button(name)
            else:
                rb = self.create_radio_button(group, name, font,
                    self.set_font_event)
                if fontcls == urwid.Thin6x6Font:
                    chosen_font_rb = rb
                    exit_font = font
            self.font_buttons.append( rb )

        # Create BigText
        self.bigtext = urwid.BigText("", None)
        bt = SwitchingPadding(self.bigtext, 'left', None)
        bt = urwid.AttrWrap(bt, 'bigtext')
        bt = urwid.Filler(bt, 'bottom', None, 7)
        bt = urwid.BoxAdapter(bt, 7)

        # Create chars_avail
        cah = urwid.Text("Characters Available:")
        self.chars_avail = urwid.Text("", wrap='any')
        ca = urwid.AttrWrap(self.chars_avail, 'chars')

        chosen_font_rb.set_state(True) # causes set_font_event call

        # Create Edit widget
        edit = self.create_edit("", "Urwid "+urwid.__version__,
            self.edit_change_event)

        # ListBox
        chars = urwid.Pile([cah, ca])
        fonts = urwid.Pile([urwid.Text("Fonts:")] + self.font_buttons,
            focus_item=1)
        col = urwid.Columns([('fixed',16,chars), fonts], 3,
            focus_column=1)
        bt = urwid.Pile([bt, edit], focus_item=1)
        l = [bt, urwid.Divider(), col]
        w = urwid.ListBox(urwid.SimpleListWalker(l))

        # Frame
        w = urwid.AttrWrap(w, 'body')
        hdr = urwid.Text("Urwid BigText example program - F8 exits.")
        hdr = urwid.AttrWrap(hdr, 'header')
        w = urwid.Frame(header=hdr, body=w)

        # Exit message
        exit = urwid.BigText(('exit'," Quit? "), exit_font)
        exit = urwid.Overlay(exit, w, 'center', None, 'middle', None)
        return w, exit
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def setup_view(self):
        fonts = urwid.get_all_fonts()
        # setup mode radio buttons
        self.font_buttons = []
        group = []
        utf8 = urwid.get_encoding_mode() == "utf8"
        for name, fontcls in fonts:
            font = fontcls()
            if font.utf8_required and not utf8:
                rb = self.create_disabled_radio_button(name)
            else:
                rb = self.create_radio_button(group, name, font,
                    self.set_font_event)
                if fontcls == urwid.Thin6x6Font:
                    chosen_font_rb = rb
                    exit_font = font
            self.font_buttons.append( rb )

        # Create BigText
        self.bigtext = urwid.BigText("", None)
        bt = SwitchingPadding(self.bigtext, 'left', None)
        bt = urwid.AttrWrap(bt, 'bigtext')
        bt = urwid.Filler(bt, 'bottom', None, 7)
        bt = urwid.BoxAdapter(bt, 7)

        # Create chars_avail
        cah = urwid.Text("Characters Available:")
        self.chars_avail = urwid.Text("", wrap='any')
        ca = urwid.AttrWrap(self.chars_avail, 'chars')

        chosen_font_rb.set_state(True) # causes set_font_event call

        # Create Edit widget
        edit = self.create_edit("", "Urwid "+urwid.__version__,
            self.edit_change_event)

        # ListBox
        chars = urwid.Pile([cah, ca])
        fonts = urwid.Pile([urwid.Text("Fonts:")] + self.font_buttons,
            focus_item=1)
        col = urwid.Columns([('fixed',16,chars), fonts], 3,
            focus_column=1)
        bt = urwid.Pile([bt, edit], focus_item=1)
        l = [bt, urwid.Divider(), col]
        w = urwid.ListBox(urwid.SimpleListWalker(l))

        # Frame
        w = urwid.AttrWrap(w, 'body')
        hdr = urwid.Text("Urwid BigText example program - F8 exits.")
        hdr = urwid.AttrWrap(hdr, 'header')
        w = urwid.Frame(header=hdr, body=w)

        # Exit message
        exit = urwid.BigText(('exit'," Quit? "), exit_font)
        exit = urwid.Overlay(exit, w, 'center', None, 'middle', None)
        return w, exit