Python urwid.Frame() Examples

The following are 30 code examples of urwid.Frame(). 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: TerminusBrowser.py    From TerminusBrowser with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def buildAddHeaderView(self, focusView):
        try:
            headerStringLeft = urwid.AttrWrap(urwid.Text(focusView.frame.headerString), 'header')
        except:
            headerStringLeft = urwid.AttrWrap(urwid.Text(''), 'header')

        if len(self.watched) > 0:
            headerStringRight = urwid.AttrWrap(urwid.Text(str(self.totalNewPosts) + ' new posts in ' + str(len(self.watched)) + ' watched thread(s)', 'right'), 'header')
        else:
            headerStringRight = urwid.AttrWrap(urwid.Text(''), 'header')

        builtUrwidSplits = buildUrwidFromSplits(self.splitTuple)
        log.debug(type(builtUrwidSplits))
        self.body = urwid.Frame(urwid.AttrWrap(builtUrwidSplits, 'body'))

        headerWidget = urwid.Columns([headerStringLeft, headerStringRight])
        self.body.header = headerWidget 
Example #3
Source File: gui.py    From wsstat with MIT License 6 votes vote down vote up
def __init__(self, client):
        self.client = client

        self.screen = urwid.raw_display.Screen()
        # self.screen = self.DummyScreen()

        self.frame = urwid.Frame(
            client.default_view,
            footer=urwid.Text("", align='center'),
        )

        self.client.frame = self.frame

        self.urwid_loop = urwid.MainLoop(
            self.frame,
            screen=self.screen,
            palette=palette,
            event_loop=self.FixedAsyncLoop(loop=client.loop),
            unhandled_input=client.handle_keypresses,
            pop_ups=True
        ) 
Example #4
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 #5
Source File: home.py    From terminal-leetcode with MIT License 6 votes vote down vote up
def __init__(self, data, header):
        title = [
            (4, urwid.AttrWrap(urwid.Text('#'), 'body', 'focus')),
            (2, urwid.AttrWrap(urwid.Text(''), 'body', 'focus')),
            (10, urwid.AttrWrap(urwid.Text('Tag'), 'body', 'focus')),
            urwid.AttrWrap(urwid.Text('Title'), 'body', 'focus'),
            (15, urwid.AttrWrap(urwid.Text('Acceptance'), 'body', 'focus')),
            (15, urwid.AttrWrap(urwid.Text('Difficulty'), 'body', 'focus')),
        ]
        title_column = urwid.Columns(title)
        self.marks = load_marks()
        items = make_itemwidgets(data, self.marks)
        self.listbox = urwid.ListBox(urwid.SimpleListWalker(items))
        header_pile = urwid.Pile([header, title_column])
        urwid.Frame.__init__(self, urwid.AttrWrap(self.listbox, 'body'), header=header_pile)
        self.last_sort = {'attr': 'id', 'reverse': True}
        self.last_search_text = None 
Example #6
Source File: main.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def __init__(self, session, debug=False):
        self.loop =None
        self.session = session
        self.footer = urwid.AttrMap(
                urwid.Text([
                        ("key", "ESC"), " Quit  ",
                        ("key", "Tab"), " Move Selection  ",
                        ("key", "F1"), " Help  ",
                        ("key", "F2"), " Reset ",
                        ("key", "F5"), " Add Test Case ",
                        ("key", "F6"), " Add Test Suite ",
                        ("key", "F9"), " Add Equipment ",
                        ("key", "F10"), " Add Environment ",
                    ]),
                "foot")
        self.reset()
        self.top = urwid.Frame(urwid.AttrMap(self.form, 'body'), footer=self.footer)
        if debug:
            from pycopia import logwindow
            widgets.DEBUG = logwindow.DebugLogWindow() 
Example #7
Source File: widgets.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        # buttons
        done = urwid.Button("Done")
        urwid.connect_signal(done, 'click', self._done_multiselect)
        done = urwid.AttrWrap(done, 'selectable', 'butfocus')
        add = urwid.Button("Add New")
        urwid.connect_signal(add, 'click', self._add_new)
        add = urwid.AttrWrap(add, 'selectable', 'butfocus')
        cancel = urwid.Button("Cancel")
        urwid.connect_signal(cancel, 'click', self._cancel)
        cancel = urwid.AttrWrap(cancel, 'selectable', 'butfocus')
        # footer and header
        header = urwid.GridFlow([done, add, cancel], 15, 3, 1, 'center')
        footer = urwid.Padding(urwid.Text(
            ("popup", "Tab to button box to select buttons. Arrow keys transfer selection.")))
        body = self._build_body()
        return urwid.Frame(body, header=header, footer=footer, focus_part="body") 
Example #8
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 Equipment"), "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, ("model", "name", "serno")),
                ("Localization", ("language",)),
                ("Asset management", ("owner", "location", "sublocation", "vendor")),
                ("Automation", ("account",)),
                ("structural relationship", ('parent',)),
                ("Addtional Info", ("comments",)),
                ]:
            if groupname:
                formstack.append(self.build_divider(groupname))
            for colname in group:
                colmd = self.metadata[colname]
                wid = self.build_input(colmd)
                formstack.append(wid)
        data = self.get_default_data(["active", "addeddate"])
        formstack.append(self.get_form_buttons(data, create=True))
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
Example #9
Source File: home.py    From terminal-leetcode with MIT License 6 votes vote down vote up
def keypress(self, size, key):
        key = vim_key_map(key)
        ignore_key = ('h', 'left')
        if key in ignore_key:
            pass
        elif key == '1':
            self.sort_list('id')
        elif key == '2':
            self.sort_list('title')
        elif key == '3':
            self.sort_list('acceptance')
        elif key == '4':
            self.sort_list('difficulty', conversion=self.difficulty_conversion)
        elif key == 'home':
            self.listbox.focus_position = 0
        elif key == 'end':
            self.listbox.focus_position = len(self.listbox.body) - 1
        elif key == 'n':
            self.handle_search(self.last_search_text, True)
        else:
            return urwid.Frame.keypress(self, size, key) 
Example #10
Source File: runner.py    From pycopia with Apache License 2.0 6 votes vote down vote up
def build(self):
        environments = db.get_environment_names()
        reports = [None] + db.get_report_names()

        self._envsel = widgets.ListScrollSelector(environments)
        self._repsel = widgets.ListScrollSelector(reports)
        self._tclist = urwid.SimpleListWalker([])
        butcols = urwid.Columns([
                ("pack", urwid.Text("environment:")),
                AM(self._envsel, "selectable", "butfocus"),
                ("pack", urwid.Text("report:")),
                AM(self._repsel, "selectable", "butfocus"),
            ], dividechars=2)
        header = urwid.Pile([
        AM(urwid.Text("Select environment, report, and set options. Use Tab to switch to environment selector. Selected:"), "subhead"),
                urwid.BoxAdapter(urwid.ListBox(self._tclist), 2),
                butcols,
        ])
        body = self._build_test_selector(False)
        return urwid.Frame(body, header=header, focus_part="body") 
Example #11
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 #12
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 #13
Source File: test_container.py    From anyMesh-Python with MIT License 6 votes vote down vote up
def ftbtest(self, desc, focus_part, header_rows, footer_rows, size,
            focus, top, bottom):
        class FakeWidget:
            def __init__(self, rows, want_focus):
                self.ret_rows = rows
                self.want_focus = want_focus
            def rows(self, size, focus=False):
                assert self.want_focus == focus
                return self.ret_rows
        header = footer = None
        if header_rows:
            header = FakeWidget(header_rows,
                focus and focus_part == 'header')
        if footer_rows:
            footer = FakeWidget(footer_rows,
                focus and focus_part == 'footer')

        f = urwid.Frame(None, header, footer, focus_part)

        rval = f.frame_top_bottom(size, focus)
        exp = (top, bottom), (header_rows, footer_rows)
        assert exp == rval, "%s expected %r but got %r"%(
            desc,exp,rval) 
Example #14
Source File: gui.py    From certstream-python with MIT License 6 votes vote down vote up
def setup_widgets(self):
        self.intro_frame = urwid.LineBox(
            urwid.Filler(
                urwid.Text(('body_text', self.INTRO_MESSAGE.format("")), align=urwid.CENTER),
                valign=urwid.MIDDLE,
            )
        )

        self.frame = urwid.Frame(
            body=self.intro_frame,
            footer=urwid.Text(
                [self.FOOTER_START, ('heartbeat_inactive', self.HEARTBEAT_ICON)],
                align=urwid.CENTER
            )
        )

        self.loop = urwid.MainLoop(
            urwid.AttrMap(self.frame, 'body_text'),
            unhandled_input=show_or_exit,
            palette=PALETTE,
        )

        self.list_walker = urwid.SimpleListWalker(self.message_list)
        self.list_box = urwid.ListBox(self.list_walker)
        urwid.connect_signal(self.list_walker, "modified", self.item_focused) 
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("Create Corporation"), "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", "address", "country", "contact", "notes"):
            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 #16
Source File: test_container.py    From anyMesh-Python with MIT License 6 votes vote down vote up
def test_focus_path(self):
        # big tree of containers
        t = urwid.Text(u'x')
        e = urwid.Edit(u'?')
        c = urwid.Columns([t, e, t, t])
        p = urwid.Pile([t, t, c, t])
        a = urwid.AttrMap(p, 'gets ignored')
        s = urwid.SolidFill(u'/')
        o = urwid.Overlay(e, s, 'center', 'pack', 'middle', 'pack')
        lb = urwid.ListBox(urwid.SimpleFocusListWalker([t, a, o, t]))
        lb.focus_position = 1
        g = urwid.GridFlow([t, t, t, t, e, t], 10, 0, 0, 'left')
        g.focus_position = 4
        f = urwid.Frame(lb, header=t, footer=g)

        self.assertEqual(f.get_focus_path(), ['body', 1, 2, 1])
        f.set_focus_path(['footer']) # same as f.focus_position = 'footer'
        self.assertEqual(f.get_focus_path(), ['footer', 4])
        f.set_focus_path(['body', 1, 2, 2])
        self.assertEqual(f.get_focus_path(), ['body', 1, 2, 2])
        self.assertRaises(IndexError, lambda: f.set_focus_path([0, 1, 2]))
        self.assertRaises(IndexError, lambda: f.set_focus_path(['body', 2, 2]))
        f.set_focus_path(['body', 2]) # focus the overlay
        self.assertEqual(f.get_focus_path(), ['body', 2, 1]) 
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("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 #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 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 #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 {}".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 #20
Source File: test_container.py    From anyMesh-Python with MIT License 5 votes vote down vote up
def test_frame(self):
        self.wstest(urwid.Frame(urwid.SolidFill()))
        self.wstest(urwid.Frame(urwid.SolidFill(),
            header=urwid.Text("hello")))
        self.wstest(urwid.Frame(urwid.SolidFill(),
            header=urwid.Text("hello"),
            footer=urwid.Text("hello"))) 
Example #21
Source File: loading.py    From terminal-leetcode with MIT License 5 votes vote down vote up
def __init__(self, text, width, host_view, loop=None):
        self.loop = loop
        self.host_view = host_view
        self.overlay = urwid.Overlay(
            urwid.LineBox(urwid.Text(text)), host_view,  # urwid.SolidFill(),
            'center', width, 'middle', None)
        urwid.Frame.__init__(self, self.overlay) 
Example #22
Source File: detail.py    From terminal-leetcode with MIT License 5 votes vote down vote up
def __init__(self, quiz, loop=None):
        self.quiz = quiz
        self.loop = loop
        self.logger = logging.getLogger(__name__)
        blank = urwid.Divider()
        view_title = urwid.AttrWrap(urwid.Text(self.quiz.title), 'body')
        view_text = self.make_body_widgets()
        view_code_title = urwid.Text('\n --- Sample Code ---\n')
        view_code = urwid.Text(self.quiz.sample_code)
        listitems = [blank, view_title, blank] + view_text + \
                    [blank, view_code_title, blank, view_code, blank]
        self.listbox = urwid.ListBox(urwid.SimpleListWalker(listitems))
        urwid.Frame.__init__(self, self.listbox) 
Example #23
Source File: help.py    From terminal-leetcode with MIT License 5 votes vote down vote up
def keypress(self, size, key):
        ignore_key = ('H', 'l', 'right', 'enter')
        if key in ignore_key:
            pass
        else:
            return urwid.Frame.keypress(self, size, key) 
Example #24
Source File: help.py    From terminal-leetcode with MIT License 5 votes vote down vote up
def __init__(self):
        title = urwid.AttrWrap(urwid.Text('Help'), 'body')
        body = urwid.Text(HelpView.__doc__)
        pile = urwid.Pile([title, body])
        filler = urwid.Filler(pile)
        urwid.Frame.__init__(self, filler) 
Example #25
Source File: result.py    From terminal-leetcode with MIT License 5 votes vote down vote up
def keypress(self, size, key):
        key = vim_key_map(key)
        if key == 'esc':
            self.destroy()
        else:
            return urwid.Frame.keypress(self, size, key) 
Example #26
Source File: result.py    From terminal-leetcode with MIT License 5 votes vote down vote up
def __init__(self, quiz, host_view, result, loop=None):
        self.quiz = quiz
        self.host_view = host_view
        self.result = result
        self.loop = loop
        self.logger = logging.getLogger(__name__)
        if result:
            if 'status_code' not in result:
                raise ValueError('Unknow result format: %s' % json.dumps(result))
            if result['status_code'] == 20:
                self.listbox = self.make_compile_error_view()
            elif result['status_code'] == 10:
                self.listbox = self.make_success_view()
            elif result['status_code'] == 11:
                self.listbox = self.make_failed_view()
            elif result['status_code'] == 12:  # memeory limit exceeded
                self.listbox = self.make_unified_error_view("Memory Limit Exceeded")
            elif result['status_code'] == 13:  # output limit exceeded
                self.listbox = self.make_unified_error_view("Output Limit Exceeded")
            elif result['status_code'] == 14:  # timeout
                self.listbox = self.make_unified_error_view("Time Limit Exceeded")
            elif result['status_code'] == 15:
                self.listbox = self.make_runtime_error_view()
            else:
                raise ValueError('Unknow status code: %d' % result['status_code'])
        else:
            raise ValueError('result shouldn\'t be None')

        self.overlay = urwid.Overlay(
            urwid.LineBox(self.listbox), host_view,
            align='center', width=('relative', 95),
            valign='middle', height=('relative', 95),
            min_width=40, min_height=40)

        footer = urwid.Pile([urwid.Text('Press Esc to close this view.', align='center'), urwid.Divider()])
        urwid.Frame.__init__(self, self.overlay, footer=footer) 
Example #27
Source File: dialog.py    From redial with GNU General Public License v3.0 5 votes vote down vote up
def show(self, loop):
        # Header
        header_text = urwid.Text(self.title, align='center')
        header = urwid.AttrMap(header_text, 'dialog')

        # Footer
        ok_btn = urwid.Button('Ok', self.on_ok)
        ok_btn = urwid.AttrWrap(ok_btn, 'dialog_button', 'dialog_button_focus')

        footer = urwid.GridFlow([ok_btn], 12, 1, 1, 'center')

        body = urwid.Filler(
            urwid.Pile([
                urwid.Text(self.message),
                urwid.Text(""),
                footer
            ])
        )

        # Layout
        layout = urwid.Frame(
            body,
            header=header
        )

        w = DialogOverlay(
            on_close=self.on_close,
            on_enter=self.on_ok,
            top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"),
            bottom_w=loop.widget,
            align='center',
            width=40,
            valign='middle',
            height=10
        )

        loop.widget = w 
Example #28
Source File: dialog.py    From redial with GNU General Public License v3.0 5 votes vote down vote up
def show(self, loop):
        # Header
        header_text = urwid.Text('Select Public SSH Key to Copy', align='center')
        header = urwid.AttrMap(header_text, 'dialog')

        cancel_btn = urwid.Button('Cancel', self.on_cancel)
        cancel_btn = urwid.AttrWrap(cancel_btn, 'dialog_button', 'dialog_button_focus')

        footer = urwid.GridFlow([cancel_btn], 12, 1, 1, 'center')

        list_box = urwid.BoxAdapter(SSHListBox(on_enter=self.on_copy, body=self.ssh_keys_walker), 5)

        body = urwid.Filler(
            urwid.Pile([list_box, footer])
        )

        # Layout
        layout = urwid.Frame(
            body=body,
            header=header)

        layout = urwid.AttrWrap(layout, 'dialog')

        w = DialogOverlay(
            on_close=lambda: self.on_close(),
            on_enter=self.on_copy,
            top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"),
            bottom_w=loop.widget,
            align='center',
            width=40,
            valign='middle',
            height=10
        )

        loop.widget = w 
Example #29
Source File: dialog.py    From redial with GNU General Public License v3.0 5 votes vote down vote up
def show(self, loop):
        # Header
        header_text = urwid.Text('Edit Folder' if self.target.name else "Add Folder", align='center')
        header = urwid.AttrMap(header_text, 'dialog')

        # Footer
        save_btn = urwid.Button('Save', self.on_save)
        save_btn = urwid.AttrWrap(save_btn, 'dialog_button', 'dialog_button_focus')

        cancel_btn = urwid.Button('Cancel', self.on_cancel)
        cancel_btn = urwid.AttrWrap(cancel_btn, 'dialog_button', 'dialog_button_focus')

        footer = urwid.GridFlow([save_btn, cancel_btn], 12, 1, 1, 'center')

        body = urwid.Filler(
            urwid.Pile([self.folder_name, footer])
        )

        # Layout
        layout = urwid.Frame(
            body,
            header=header)

        w = DialogOverlay(
            on_close=lambda: self.on_close(self.target),
            on_enter=self.on_save,
            top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"),
            bottom_w=loop.widget,
            align='center',
            width=40,
            valign='middle',
            height=10
        )

        loop.widget = w 
Example #30
Source File: dialog.py    From redial with GNU General Public License v3.0 5 votes vote down vote up
def show(self, loop):
        # Header
        header_text = urwid.Text('Remove Connection: ' + self.target.name, align='center')
        header = urwid.AttrMap(header_text, 'dialog')

        # Footer
        ok_btn = urwid.Button('Ok', self.on_ok)
        ok_btn = urwid.AttrWrap(ok_btn, 'dialog_button', 'dialog_button_focus')

        cancel_btn = urwid.Button('Cancel', self.on_cancel)
        cancel_btn = urwid.AttrWrap(cancel_btn, 'dialog_button', 'dialog_button_focus')

        footer = urwid.GridFlow([ok_btn, cancel_btn], 12, 1, 1, 'center')

        body = urwid.Filler(
            urwid.Pile([
                urwid.Text("Are you sure?"),
                urwid.Text(""),
                footer
            ])
        )

        # Layout
        layout = urwid.Frame(
            body,
            header=header
        )

        w = DialogOverlay(
            on_close=lambda: self.on_close(self.target),
            on_enter=lambda: self.on_ok(None),
            top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"),
            bottom_w=loop.widget,
            align='center',
            width=40,
            valign='middle',
            height=10
        )

        loop.widget = w