Python urwid.Divider() Examples

The following are 30 code examples of urwid.Divider(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module urwid , or try the search function .
Example #1
Source File: components.py    From sclack with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, name, status=None, timezone=None, phone=None, email=None, skype=None):
        line = urwid.Divider('─')
        header = urwid.Pile([
            line,
            urwid.Text([' ', name]),
            line
        ])
        contents = []
        if status:
            contents.append(self.format_row('status', status))
        if timezone:
            contents.append(self.format_row('timezone', timezone))
        if phone:
            contents.append(self.format_row('phone', phone))
        if email:
            contents.append(self.format_row('email', email))
        if skype:
            contents.append(self.format_row('skype', skype))
        self.pile = urwid.Pile(contents)
        body = urwid.Frame(urwid.Filler(self.pile, valign='top'), header, line)
        super(ProfileSideBar, self).__init__(body, 'profile') 
Example #2
Source File: chanBoardBuilder.py    From TerminusBrowser with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def buildFrame(self, board):
        '''returns the board widget'''

        threadButtonList = []

        for threadNumber, threadInfo in self.threadsDict.items():
            title = str(threadInfo[0]).replace('-', ' ')
            if self.uFilter:
                if re.search(self.uFilter.lower(), title.lower()):
                    threadButton = urwid.Button(str(threadNumber), self.changeFrameThread)
                    threadInfo = urwid.Text(self.info_text.format(str(threadInfo[1]),str(threadInfo[2])))
                    threadList = [threadButton, urwid.Divider('-'), urwid.Divider(), urwid.Text(title), urwid.Divider(), urwid.Divider('-'), threadInfo]
                    threadButtonList.append(urwid.LineBox(urwid.Pile(threadList)))
            else:
                threadButton = urwid.Button(str(threadNumber), self.changeFrameThread)
                threadInfo = urwid.Text(self.info_text.format(str(threadInfo[1]), str(threadInfo[2])))
                threadList = [threadButton, urwid.Divider('-'), urwid.Divider(), urwid.Text(title), urwid.Divider(), urwid.Divider('-'), threadInfo]
                threadButtonList.append(urwid.LineBox(urwid.Pile(threadList)))

        self.parsedItems = len(threadButtonList)
        catalogueButtons = urwid.GridFlow(threadButtonList, 30, 2, 2, 'center')
        listbox = urwid.ListBox(urwid.SimpleListWalker([catalogueButtons]))

        self.uvm.itemCount = len(threadButtonList)
        return urwid.Pile([listbox]) 
Example #3
Source File: host_definition.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 6 votes vote down vote up
def render_page(self):

        host_widgets = urwid.Padding(self.host_panels,
                                    left=2, right=2)

        return urwid.AttrMap(
                 urwid.Filler(
                   urwid.Pile([
                               urwid.Padding(urwid.Text(self.text),
                                             left=2, right=2),
                               urwid.Divider(),
                               host_widgets,
                               urwid.Divider(),
                               self.next_btn]),
                   valign='top',top=1),
                 'active_step') 
Example #4
Source File: debug.py    From clay with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, app):
        self.app = app
        self.walker = urwid.SimpleListWalker([])
        for log_record in logger.get_logs():
            self._append_log(log_record)
        logger.on_log_event += self._append_log
        self.listbox = urwid.ListBox(self.walker)

        self.debug_data = urwid.Text('')

        super(DebugPage, self).__init__([
            ('pack', self.debug_data),
            ('pack', urwid.Text('')),
            ('pack', urwid.Text('Hit "Enter" to copy selected message to clipboard.')),
            ('pack', urwid.Divider(u'\u2550')),
            self.listbox
        ])

        gp.auth_state_changed += self.update

        self.update() 
Example #5
Source File: views.py    From zulip-terminal with Apache License 2.0 6 votes vote down vote up
def __init__(self, controller: Any, question: Any,
                 success_callback: Callable[[], bool]):
        self.controller = controller
        self.success_callback = success_callback
        yes = urwid.Button('Yes', self.exit_popup_yes)
        no = urwid.Button('No', self.exit_popup_no)
        yes._w = urwid.AttrMap(urwid.SelectableIcon(
            'Yes', 4), None, 'selected')
        no._w = urwid.AttrMap(urwid.SelectableIcon(
            'No', 4), None, 'selected')
        display_widget = urwid.GridFlow([yes, no], 3, 5, 1, 'center')
        wrapped_widget = urwid.WidgetWrap(display_widget)
        prompt = urwid.LineBox(
            urwid.ListBox(
                urwid.SimpleFocusListWalker(
                    [question, urwid.Divider(), wrapped_widget]
                )))
        urwid.Overlay.__init__(self, prompt, self.controller.view,
                               align="left", valign="top",
                               width=self.controller.view.LEFT_WIDTH + 1,
                               height=8) 
Example #6
Source File: test_ui_tools.py    From zulip-terminal with Apache License 2.0 6 votes vote down vote up
def test_main_view_generates_stream_header(self, mocker, message,
                                               to_vary_in_last_message):
        self.model.stream_dict = {
            5: {
                'color': '#bd6',
            },
        }
        last_message = dict(message, **to_vary_in_last_message)
        msg_box = MessageBox(message, self.model, last_message)
        view_components = msg_box.main_view()
        assert len(view_components) == 3

        assert isinstance(view_components[0], Columns)

        assert isinstance(view_components[0][0], Text)
        assert isinstance(view_components[0][1], Text)
        assert isinstance(view_components[0][2], Divider) 
Example #7
Source File: storyFrame.py    From TerminusBrowser with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def buildFrame(self, board):
        '''returns the board widget'''

        threadButtonList = []

        for title, l, s, c, t  in self.titles.items():
            if self.uFilter:
                if re.search(self.uFilter.lower(), title.lower()):
                    threadButton = urwid.Button(str(l), self.changeFrameThread)
                    threadInfo = urwid.Text(self.info_text.format(str(s),str(c)))
                    threadList = [threadButton, urwid.Divider('-'), urwid.Divider(), urwid.Text(title), urwid.Divider(), urwid.Divider('-'), threadInfo]
                    threadButtonList.append(urwid.LineBox(urwid.Pile(threadList)))
            else:
                threadButton = urwid.Button(str(l), self.changeFrameThread)
                threadInfo = urwid.Text(self.info_text.format(str(s),str(c)))
                threadList = [threadButton, urwid.Divider('-'), urwid.Divider(), urwid.Text(title), urwid.Divider(), urwid.Divider('-'), threadInfo]
                threadButtonList.append(urwid.LineBox(urwid.Pile(threadList)))

        self.parsedItems = len(threadButtonList)
        catalogueButtons = urwid.GridFlow(threadButtonList, 30, 2, 2, 'center')
        listbox = urwid.ListBox(urwid.SimpleListWalker([catalogueButtons]))

        self.uvm.itemCount = len(threadButtonList)
        return [listbox] 
Example #8
Source File: test_ui_tools.py    From zulip-terminal with Apache License 2.0 6 votes vote down vote up
def test_streams_view(self, mocker, streams, pinned, width=40):
        self.view.unpinned_streams = [s for s in streams if s[1] not in pinned]
        self.view.pinned_streams = [s for s in streams if s[1] in pinned]
        stream_button = mocker.patch(VIEWS + '.StreamButton')
        stream_view = mocker.patch(VIEWS + '.StreamsView')
        line_box = mocker.patch(VIEWS + '.urwid.LineBox')
        divider = mocker.patch(VIEWS + '.urwid.Divider')
        mocker.patch(STREAMBUTTON + ".mark_muted")

        left_col_view = LeftColumnView(width, self.view)

        if pinned:
            divider.assert_called_once_with('-')
        else:
            divider.assert_not_called()

        stream_button.assert_has_calls(
            [mocker.call(stream,
                         controller=self.view.controller,
                         width=width,
                         view=self.view,
                         count=1)
             for stream in (self.view.pinned_streams
                            + self.view.unpinned_streams)]) 
Example #9
Source File: watcherFrame.py    From TerminusBrowser with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def buildThread(self):
        watcherWidgetList = []
        self.uvm.watcherUpdate(None, None)
        for wT, wTDict in self.uvm.watched.items():
            if 'isArchived' in wTDict:
                wInfo = urwid.Text(f"Board: {wTDict['board']} -- {wTDict['op']} | THREAD ARCHIVED")
            else:
                wInfo = urwid.Text(f"Board: {wTDict['board']} -- {wTDict['op']} | Unread: {wTDict['numReplies']}")

            wButton = urwid.Button(f'View thread: {wT}', self.viewThread)
            dButton = urwid.Button(f'Unwatch thread: {wT}', self.unwatchThread)
            watcherWidgetList.append(urwid.LineBox(urwid.Pile([wInfo, urwid.Divider('-'), wButton, dButton])))

        self.parsedItems = len(watcherWidgetList)

        listbox_content = watcherWidgetList
        listbox = urwid.ListBox(urwid.SimpleListWalker(listbox_content))

        return listbox 
Example #10
Source File: historyFrame.py    From TerminusBrowser with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def buildThread(self):
        historyWidgetList = []
        for h in self.uvm.history:
            frame = h[0]
            factory = h[1]
            args = h[2]

            if self.uFilter:
                if self.uFilter in args:
                    hInfo = urwid.Text(f'Frame: {frame}, Info: {args}')
                    hButton = urwid.Button(f'{self.uvm.history.index(h)}: Restore', self.restore)
                    historyWidgetList.append(urwid.LineBox(urwid.Pile([hInfo, urwid.Divider('-'), hButton])))
            else:
                hInfo = urwid.Text(f'Frame: {frame}, Info: {args}')
                hButton = urwid.Button(f'{self.uvm.history.index(h)}: Restore', self.restore)
                historyWidgetList.append(urwid.LineBox(urwid.Pile([hInfo, urwid.Divider('-'), hButton])))

        self.parsedItems = len(historyWidgetList)

        listbox_content = historyWidgetList
        listbox = urwid.ListBox(urwid.SimpleListWalker(listbox_content))

        return listbox 
Example #11
Source File: result.py    From terminal-leetcode with MIT License 6 votes vote down vote up
def make_compile_error_view(self):
        blank = urwid.Divider()
        status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body')
        status = urwid.AttrWrap(urwid.Text('Compile Error'), 'hometag')
        columns = urwid.Columns([(17, status_header), (20, status)])
        column_wrap = urwid.WidgetWrap(columns)
        result_header = urwid.Text('--- Run Code Result: ---', align='center')
        your_input_header = urwid.Text('Your input:')
        your_input = urwid.Text('')
        your_answer_header = urwid.Text('Your answer:')
        your_answer = urwid.Text(self.result['compile_error'])
        expected_answer_header = urwid.Text('Expected answer:')
        expected_answer = urwid.Text('Unkown Error')
        list_items = [
            result_header,
            blank, column_wrap,
            blank, your_input_header, your_input,
            blank, your_answer_header, your_answer,
            blank, expected_answer_header, expected_answer
        ]
        self._append_stdout_if_non_empty(list_items)
        return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2) 
Example #12
Source File: result.py    From terminal-leetcode with MIT License 6 votes vote down vote up
def make_failed_view(self):
        blank = urwid.Divider()
        status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body')
        status = urwid.AttrWrap(urwid.Text('Wrong Answer'), 'hometag')
        columns = urwid.Columns([(17, status_header), (20, status)])
        result_header = urwid.Text('--- Run Code Result: ---', align='center')
        passed_header = urwid.Text('Passed test cases:')
        s = self.result['compare_result']
        passed = urwid.Text('%d/%d' % (s.count('1'), len(s)))
        your_input_header = urwid.Text('Your input:')
        your_input = urwid.Text(self.result['input'])
        your_answer_header = urwid.Text('Your answer:')
        your_answer = urwid.Text(self.result['code_output'])
        expected_answer_header = urwid.Text('Expected answer:')
        expected_answer = urwid.Text(self.result['expected_output'])
        list_items = [
            result_header,
            blank, columns,
            blank, passed_header, passed,
            blank, your_input_header, your_input,
            blank, your_answer_header, your_answer,
            blank, expected_answer_header, expected_answer
        ]
        self._append_stdout_if_non_empty(list_items)
        return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2) 
Example #13
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        menulist = []
        # big title
        bt = urwid.BigText("Storage Editor", urwid.HalfBlock5x4Font())
        bt = urwid.Padding(bt, "center", None)
        # primary tables for editing
        self.primlist = [TableItemWidget(s) for s in self._PRIMARY_TABLES]
        for b in self.primlist:
            urwid.connect_signal(b, 'activate', self._select)
        pmenu = urwid.GridFlow(self.primlist, 20, 2, 1, "left")
        # heading blurbs
        subhead = urwid.AttrMap(urwid.Text("Select an object type to view or edit."), "subhead")
        supportsubhead = urwid.AttrMap(urwid.Text("Select a supporting object to view or edit."), "subhead")
        # secondary/support tables
        self.seclist = [TableItemWidget(s) for s in self._SUPPORT_TABLES]
        for b in self.seclist:
            urwid.connect_signal(b, 'activate', self._select)
        smenu = urwid.GridFlow(self.seclist, 25, 1, 0, "left")
        divider = urwid.Divider("-", top=1, bottom=1)
        menulist = [bt, divider, subhead, pmenu, divider, supportsubhead, smenu]
        listbox = urwid.ListBox(urwid.SimpleListWalker(menulist))
        return urwid.Frame(listbox) 
Example #14
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        header = urwid.Pile([
                urwid.AttrMap(urwid.Text("Create Environment"), "formhead"),
                urwid.AttrMap(urwid.Text(
                        "Arrow keys navigate,"
                        "Owner is optional, it serves as a lock on the environment. "
                        "Usually you should leave it as None."), "formhead"),
                urwid.Divider(),
                ])
        formstack = []
        for colname in ("name", "owner"):
            colmd = self.metadata[colname]
            wid = self.build_input(colmd)
            formstack.append(wid)
        formstack.append(self.get_form_buttons(create=True))
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
Example #15
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        header = urwid.Pile([
                urwid.AttrMap(urwid.Text("Edit {}".format(self.modelclass.__name__)), "formhead"),
                urwid.AttrMap(urwid.Text("Arrow keys navigate, "
                        "Enter to select form button. Tab to switch to header."
                        "Type into other fields."), "formhead"),
                AM(urwid.Button("Copy from...", on_press=self._create_copy_input), "selectable", "butfocus"),
                urwid.Divider(),
                ])
        formstack = []
        for colname in ("name", "owner"):
            colmd = self.metadata[colname]
            wid = self.build_input(colmd, getattr(self.row, colmd.colname))
            formstack.append(wid)
        colmd = self.metadata["attributes"]
        wid = self.build_attribute_input(colmd, getattr(self.row, colmd.colname))
        formstack.append(wid)
        # test equipment
        colmd = self.metadata["testequipment"]
        tewid = self.build_testequipment_input(colmd, getattr(self.row, "testequipment"))
        formstack.append(tewid)
        # common buttons
        formstack.append(self.get_form_buttons())
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
Example #16
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        header = urwid.Pile([
                urwid.AttrMap(urwid.Text("Create Interface"), "formhead"),
                urwid.AttrMap(urwid.Text("Arrow keys navigate, Enter to select form button. Type into other fields."), "formhead"),
                urwid.Divider(),
                ])
        formstack = []
        for groupname, group in [
                (None, ("name", "alias", "ifindex", "description")),
                ("Network Address", ("ipaddr",)),
                ("Media Access Address", ("macaddr", "vlan")),
                ("Extra Info", ("interface_type", "mtu", "speed")),
                ("Administrative", ("status",)),
                ("Associations", ("network", "parent")),
                ]:
            if groupname:
                formstack.append(self.build_divider(groupname))
            for colname in group:
                colmd = self.metadata[colname]
                wid = self.build_input(colmd)
                formstack.append(wid)
        formstack.append(self.get_form_buttons(create=True))
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
Example #17
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        header = urwid.Pile([
                urwid.AttrMap(urwid.Text("Edit Interface"), "formhead"),
                urwid.AttrMap(urwid.Text("Arrow keys navigate, Enter to select form button. Type into other fields."), "formhead"),
                urwid.Divider(),
                ])
        formstack = []
        for groupname, group in [
                (None, ("name", "alias", "ifindex", "description")),
                ("Network Address", ("ipaddr",)),
                ("Media Access Address", ("macaddr", "vlan")),
                ("Extra Info", ("interface_type", "mtu", "speed")),
                ("Administrative", ("status",)),
                ("Associations", ("network", "equipment", "parent", "subinterfaces")),
                ]:
            if groupname:
                formstack.append(self.build_divider(groupname))
            for colname in group:
                colmd = self.metadata[colname]
                wid = self.build_input(colmd, getattr(self.row, colmd.colname))
                formstack.append(wid)
        formstack.append(self.get_form_buttons())
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
Example #18
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        header = urwid.Pile([
                urwid.AttrMap(urwid.Text("Edit {}".format(self.modelclass.__name__)), "formhead"),
                urwid.AttrMap(urwid.Text("Arrow keys navigate, Enter to select form button. Type into other fields."), "formhead"),
                urwid.Divider(),
                ])
        formstack = []
        for colname in ("name", "address", "country", "contact", "notes"):
            colmd = self.metadata[colname]
            wid = self.build_input(colmd, getattr(self.row, colmd.colname))
            formstack.append(wid)
        colmd = self.metadata["attributes"]
        wid = self.build_attribute_input(colmd, getattr(self.row, colmd.colname))
        formstack.append(wid)
        # common buttons
        formstack.append(self.get_form_buttons())
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
Example #19
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        header = urwid.Pile([
                urwid.AttrMap(urwid.Text("Edit Test Case"), "formhead"),
                urwid.AttrMap(urwid.Text("Arrow keys navigate, Enter to select form button. Type into other fields."), "formhead"),
                urwid.Divider(),
                ])
        formstack = []
        for groupname, group in [
                (None, ("name", "purpose", "passcriteria")),
                ("Details", ("startcondition", "endcondition", "procedure", "prerequisites")),
                ("Management", ("valid", "automated", "interactive", "functionalarea", "testimplementation", "time_estimate", "bugid")),
                ("Requirement", ("reference", "cycle", "priority")),
                ("Status", ("status",)),
                ("Comments", ("comments",)),
                ]:
            if groupname:
                formstack.append(self.build_divider(groupname))
            for colname in group:
                colmd = self.metadata[colname]
                wid = self.build_input(colmd, getattr(self.row, colmd.colname))
                formstack.append(wid)
        data = self.get_default_data(["lastchange"])
        formstack.append(self.get_form_buttons(data))
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
Example #20
Source File: components.py    From sclack with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, text='', align='left', char='─'):
        self.text = text
        text_size = len(text if isinstance(text, str) else text[1]) + 2
        self.text_widget = ('fixed', text_size, urwid.Text(text, align='center'))
        if align == 'right':
            body = [
                urwid.Divider(char),
                self.text_widget,
                ('fixed', 1, urwid.Divider(char))
            ]
        elif align == 'center':
            body = [
                urwid.Divider(char),
                self.text_widget,
                urwid.Divider(char)
            ]
        else:
            body = [
                ('fixed', 1, urwid.Divider(char)),
                self.text_widget,
                urwid.Divider(char)
            ]
        super(TextDivider, self).__init__(body) 
Example #21
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def get_form_buttons(self, defaultdata=None, create=False):
        ok = urwid.Button("OK")
        urwid.connect_signal(ok, 'click', self._ok, defaultdata)
        ok = AM(ok, 'selectable', 'butfocus')
        cancel = urwid.Button("Cancel")
        urwid.connect_signal(cancel, 'click', self._cancel)
        cancel = AM(cancel, 'selectable', 'butfocus')
        l = [ok, cancel]
        if create:
            ok_edit = urwid.Button("OK and Edit")
            urwid.connect_signal(ok_edit, 'click', self._ok_and_edit, defaultdata)
            ok_edit = AM(ok_edit, 'selectable', 'butfocus')
            l = [ok, ok_edit, cancel]
        else:
            l = [ok, cancel]
        butgrid = urwid.GridFlow(l, 15, 3, 1, 'center')
        return urwid.Pile([urwid.Divider(), butgrid ], focus_item=1) 
Example #22
Source File: components.py    From sclack with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, text='', date=None, char='─'):
        text_size = len(text if isinstance(text, str) else text[1]) + 2
        self.text_widget = ('fixed', text_size, urwid.Text(('new_messages_text', text), align='center'))
        body = [
            urwid.Divider(char)
        ]
        if date is None:
            body.append(self.text_widget)
            body.append(('fixed', 1, urwid.Divider(char)))
        else:
            date_size = len(date if isinstance(date, str) else date[1]) + 2
            date_widget = ('fixed', date_size, urwid.Text(date, align='center'))
            body.append(date_widget)
            body.append(urwid.Divider(char))
            body.append(self.text_widget)
            body.append(('fixed', 1, urwid.Divider(char)))
        super(NewMessagesDivider, self).__init__(urwid.Columns(body), 'new_messages_line') 
Example #23
Source File: result.py    From terminal-leetcode with MIT License 6 votes vote down vote up
def make_unified_error_view(self, error_title):
        blank = urwid.Divider()
        status_header = urwid.AttrWrap(urwid.Text('Run Code Status: '), 'body')
        status = urwid.AttrWrap(urwid.Text(error_title), 'hometag')
        columns = urwid.Columns([(17, status_header), (30, status)])
        column_wrap = urwid.WidgetWrap(columns)
        if 'last_testcase' in self.result:
            result_header = urwid.Text('--- Run Code Result: ---', align='center')
            your_input_header = urwid.Text('Last executed input:')
            your_input = urwid.Text(self.result['last_testcase'])
            list_items = [
                result_header,
                blank, column_wrap,
                blank, your_input_header, your_input,
            ]
        else:
            list_items = [
                result_header,
                blank, column_wrap,
            ]
        self._append_stdout_if_non_empty(list_items)
        return urwid.Padding(urwid.ListBox(urwid.SimpleListWalker(list_items)), left=2, right=2) 
Example #24
Source File: components.py    From sclack with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, user, typing=None, is_read_only=False):
        self.read_only_widget = urwid.Text('You have no power here!', align='center')
        if typing != None:
            top_separator = TextDivider(('is_typing', '{} {} is typing...'.format(
                get_icon('keyboard'),
                typing
            )))
        else:
            top_separator = urwid.Divider('─')
        self.prompt_widget = MessagePrompt(user)
        middle = urwid.WidgetPlaceholder(self.read_only_widget if is_read_only else self.prompt_widget)
        self.body = urwid.Pile([
            urwid.WidgetPlaceholder(top_separator),
            middle,
            urwid.Divider('─')
        ])
        self._typing = typing
        super(MessageBox, self).__init__(self.body, None, {'prompt': 'active_prompt'}) 
Example #25
Source File: settings.py    From clay with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, app):
        self.app = app
        self.username = urwid.Edit(
            edit_text=settings.get('username', 'play_settings') or ''
        )
        self.password = urwid.Edit(
            mask='*', edit_text=settings.get('password', 'play_settings') or ''
        )
        self.device_id = urwid.Edit(
            edit_text=settings.get('device_id', 'play_settings') or ''
        )
        self.download_tracks = urwid.CheckBox(
            'Download tracks before playback',
            state=settings.get('download_tracks', 'play_settings') or False
        )
        self.equalizer = Equalizer()
        super(SettingsPage, self).__init__([urwid.ListBox(urwid.SimpleListWalker([
            urwid.Text('Settings'),
            urwid.Divider(' '),
            urwid.Text('Username'),
            urwid.AttrWrap(self.username, 'input', 'input_focus'),
            urwid.Divider(' '),
            urwid.Text('Password'),
            urwid.AttrWrap(self.password, 'input', 'input_focus'),
            urwid.Divider(' '),
            urwid.Text('Device ID'),
            urwid.AttrWrap(self.device_id, 'input', 'input_focus'),
            urwid.Divider(' '),
            self.download_tracks,
            urwid.Divider(' '),
            urwid.AttrWrap(urwid.Button(
                'Save', on_press=self.on_save
            ), 'input', 'input_focus'),
            urwid.Divider(u'\u2500'),
            self.equalizer,
        ]))]) 
Example #26
Source File: loading.py    From sclack with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        header = TextDivider(placeholder(size=12))
        divider = urwid.Divider('─')
        body = urwid.ListBox([
            urwid.Text(placeholder(size=20, left=2)),
            divider
        ] + [urwid.Text(placeholder(size=size, left=2))
            for size in [5, 7, 19, 8, 0, 3, 22, 14, 11, 13]])
        super(LoadingSideBar, self).__init__(body, header=header, footer=divider) 
Example #27
Source File: host_credentials.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def render_page(self):

        w = urwid.Pile([
                  urwid.Padding(urwid.Text(self.text),
                                left=1, right=1),
                  urwid.Divider(),
                  urwid.Padding(
                    urwid.Columns([
                        ("fixed", 20, self.enable_password),
                        ("fixed", 22, self.common_password)
                        ]),
                    left=1),
                  urwid.Divider(),
                  urwid.Padding(
                      urwid.Columns([
                          ("weight", 3, urwid.Pile([
                              self.pending_table_title,
                              urwid.BoxAdapter(
                                urwid.Frame(self.pending_table,
                                            header=self.pending_table_headings),
                                10),
                          ])),
                          ("weight", 1, urwid.Pile([
                              self.sshok_table_title,
                              urwid.BoxAdapter(
                                  urwid.Frame(self.sshok_table,
                                              header=self.sshok_table_headings),
                                  10),
                          ]))
                      ], dividechars=1),
                      left=1),
                  self.check_btn
              ])

        w.focus_position = 5                # the Check button widget

        return urwid.AttrMap(
                 urwid.Filler(w, valign='top', top=1),
                 "active_step") 
Example #28
Source File: spotify-restore.py    From spotify-playlists-2-deezer with MIT License 5 votes vote down vote up
def menu(title, choices):
	body = [urwid.Text(title), urwid.Text('The longest playlist has '+str(longest_playlistcount)+' entries. Do you want to modify the selection or start the import?') ,urwid.Divider()]
	for c in choices:
		button = urwid.Button(c)
		urwid.connect_signal(button, 'click', item_chosen, c)
		body.append(urwid.AttrMap(button, None, focus_map='reversed'))
	return urwid.ListBox(urwid.SimpleFocusListWalker(body))

# check if the checkbox should be selected 
Example #29
Source File: ui.py    From tildemush with GNU General Public License v3.0 5 votes vote down vote up
def menu(title, choices):
    if type(title) is str:
        title = urwid.Text(title)
    body = [title, urwid.Divider()]
    body.extend(choices)
    return urwid.ListBox(urwid.SimpleFocusListWalker(body)) 
Example #30
Source File: commit.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def render_page(self):
        return urwid.AttrMap(
                 urwid.Filler(
                   urwid.Pile([
                     urwid.Padding(
                       urwid.Text(self.text),
                       left=2, right=2),
                     urwid.Divider(),
                     self.next_btn]),
                   valign='top', top=1),
                 'active_step')