Python urwid.LineBox() Examples

The following are 30 code examples for showing how to use urwid.LineBox(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module urwid , or try the search function .

Example 1
Project: vpngate-with-proxy   Author: Dragon2fly   File: ui_elements.py    License: GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, key=None, value=('', '')):
        self.trigger = key
        self.yn = value[0]
        self.yn_but = MyButton([('attention', 'Use proxy: '), self.yn], self.on_change)
        self.input_addr = urwid.Edit(('attention', u' \N{BULLET} Address  : '), edit_text=value[1], wrap='clip')
        self.input_port = urwid.IntEdit(('attention', u' \N{BULLET} Port     : '), default=value[2])
        self.input_port.set_wrap_mode('clip')
        exit_but = urwid.Padding(urwid.Button('OKay'.center(8), self.item_callback), 'center', 12)

        widgets = [self.yn_but] \
                  + [urwid.AttrMap(wid, None, 'popbgs') for wid in (self.input_addr, self.input_port, exit_but)]

        self.pile = urwid.Pile(widgets)
        fill = urwid.LineBox(urwid.Filler(self.pile))
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))

        self.chosen = value 
Example 2
Project: zulip-terminal   Author: zulip   File: views.py    License: Apache License 2.0 6 votes vote down vote up
def topics_view(self, stream_button: Any) -> Any:
        stream_id = stream_button.stream_id
        topics_btn_list = [
            TopicButton(
                stream_id=stream_id,
                topic=topic,
                controller=self.controller,
                width=self.width,
                count=self.model.unread_counts['unread_topics'].
                get((stream_id, topic), 0)
            ) for topic in self.model.index['topics'][stream_id]]

        self.view.topic_w = TopicsView(topics_btn_list, self.view,
                                       stream_button)
        w = urwid.LineBox(
            self.view.topic_w, title="Topics",
            tlcorner='━', tline='━', lline='',
            trcorner='━', blcorner='', rline='',
            bline='', brcorner='─'
            )
        return w 
Example 3
Project: zulip-terminal   Author: zulip   File: views.py    License: 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 4
Project: zulip-terminal   Author: zulip   File: boxes.py    License: Apache License 2.0 6 votes vote down vote up
def private_box_view(self, button: Any=None, email: str='') -> None:
        self.set_editor_mode()
        if email == '' and button is not None:
            email = button.email
        self.to_write_box = ReadlineEdit("To: ", edit_text=email)
        self.msg_write_box = ReadlineEdit(multiline=True)
        self.msg_write_box.enable_autocomplete(
            func=self.generic_autocomplete,
            key=keys_for_command('AUTOCOMPLETE').pop(),
            key_reverse=keys_for_command('AUTOCOMPLETE_REVERSE').pop()
        )
        to_write_box = urwid.LineBox(
            self.to_write_box, tlcorner='─', tline='─', lline='',
            trcorner='─', blcorner='─', rline='',
            bline='─', brcorner='─'
        )
        self.contents = [
            (to_write_box, self.options()),
            (self.msg_write_box, self.options()),
        ]
        self.focus_position = 1 
Example 5
Project: conjure-up   Author: conjure-up   File: shutdown.py    License: MIT License 6 votes vote down vote up
def __init__(self, exit_code):
        self.exit_code = exit_code
        self.message = Text('Do you want to quit?', align='center')
        super().__init__(LineBox(Pile([
            Padding.line_break(""),
            self.message,
            Padding.line_break(""),
            Columns([
                Text(""),
                SubmitButton('Yes', lambda _: self.confirm()),
                Text(""),
                SubmitButton('No', lambda _: self.cancel()),
                Text(""),
            ]),
            Padding.line_break(""),
        ])))
        if events.Error.is_set():
            self.confirm() 
Example 6
Project: pycopia   Author: kdart   File: widgets.py    License: Apache License 2.0 6 votes vote down vote up
def build(self):
        wlist = []
        addnew = urwid.Button("Add")
        urwid.connect_signal(addnew, 'click', self._add_new_option)
        addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus')
        wlist.append(addnew)
        for attrib in getattr(self.row, self.metadata.colname): # list-like attribute
            entry = ListEntry(urwid.Columns(
                    [(30, urwid.Text(str(attrib.type))),
                     urwid.Text(unicode(attrib.value).encode("utf-8"))]))
            entry.attrname = attrib.type.name
            urwid.connect_signal(entry, 'activate', self._edit_option)
            urwid.connect_signal(entry, 'delete', self._delete)
            wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2)) 
Example 7
Project: pycopia   Author: kdart   File: widgets.py    License: Apache License 2.0 6 votes vote down vote up
def _create_relation_input(self):
        choices = dict(models.get_choices(self.session, self.modelclass, self.metadata.colname, None))
        addnew = urwid.Button("Add New")
        urwid.connect_signal(addnew, 'click', self._add_new_related)
        # Cancel
        canc = urwid.Button("Cancel")
        urwid.connect_signal(canc, 'click', self._cancel)
        butcol = urwid.Columns([AM(addnew, "buttn", "buttnf"), AM(canc, "buttn", "buttnf")])
        wlist = [butcol]
        if self.metadata.nullable:
            entry = ListEntry(urwid.Text("None (remove)"))
            urwid.connect_signal(entry, 'activate', self._single_select)
            wlist.append(entry)
        for pk, cname in choices.items():
            entry = ListEntry(urwid.Text(cname))
            urwid.connect_signal(entry, 'activate', self._single_select, pk)
            wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), 9) 
Example 8
Project: pycopia   Author: kdart   File: widgets.py    License: Apache License 2.0 6 votes vote down vote up
def build(self):
        addnew = urwid.Button("Add")
        urwid.connect_signal(addnew, 'click', self._add_new_testequipment)
        addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus')
        wlist = [addnew]
        for te in getattr(self.environmentrow, self.metadata.colname): # list-like attribute
            entry = ListEntry( urwid.Text(self._stringify_te(te)))
            urwid.connect_signal(entry, 'activate', self._edit_testequipment)
            urwid.connect_signal(entry, 'delete', self._delete_testequipment)
            entry.testequipment = te
            if te.UUT:
                wlist.insert(1, entry)
            else:
                wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2)) 
Example 9
Project: s-tui   Author: amanusk   File: about_menu.py    License: GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, return_fn):

        self.return_fn = return_fn

        self.about_message = ABOUT_MESSAGE

        self.time_out_ctrl = urwid.Text(self.about_message)

        cancel_button = urwid.Button('Exit', on_press=self.on_cancel)
        cancel_button._label.align = 'center'

        if_buttons = urwid.Columns([cancel_button])

        title = urwid.Text(('bold text', u"  About Menu  \n"), 'center')

        self.titles = [title,
                       self.time_out_ctrl,
                       if_buttons]

        self.main_window = urwid.LineBox(ViListBox(self.titles)) 
Example 10
Project: s-tui   Author: amanusk   File: help_menu.py    License: GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, return_fn):

        self.return_fn = return_fn

        self.help_message = HELP_MESSAGE

        self.time_out_ctrl = urwid.Text(self.help_message)

        cancel_button = urwid.Button(('Exit'), on_press=self.on_cancel)
        cancel_button._label.align = 'center'

        if_buttons = urwid.Columns([cancel_button])

        title = urwid.Text(('bold text', u"  Help Menu  \n"), 'center')

        self.titles = [title,
                       self.time_out_ctrl,
                       if_buttons]

        self.main_window = urwid.LineBox(ViListBox(self.titles)) 
Example 11
Project: certstream-python   Author: CaliDog   File: gui.py    License: 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 12
Project: redial   Author: taypo   File: dialog.py    License: GNU General Public License v3.0 6 votes vote down vote up
def show(self, loop):
        self.loop = loop
        w = DialogOverlay(
            on_close=lambda: self.on_close(self.parent),
            on_enter=self.on_save,
            top_w=urwid.AttrMap(
                urwid.LineBox(
                    self.advanced_body if self.show_advanced else self.body, self.header_text),
                "dialog"),
            bottom_w=loop.widget,
            align='center',
            width=64,
            valign='middle',
            height=11 if self.show_advanced else 8
        )

        loop.widget = w 
Example 13
Project: yTermPlayer   Author: TimeTraveller-San   File: ui.py    License: GNU General Public License v3.0 6 votes vote down vote up
def start_screen(self):
        #Ovrlay top screen at start
        txt1_1=urwid.Button("New playlist [Enter URL]")
        urwid.connect_signal(txt1_1, 'click', self.input_screen)
        txt1 = urwid.AttrMap(txt1_1,None,focus_map='reversed')
        txt2_2=urwid.Button("Load saved playlist")
        urwid.connect_signal(txt2_2, 'click', self.load_list_screen)
        txt2 = urwid.AttrMap(txt2_2,None,focus_map='reversed')
        start_list=urwid.SimpleFocusListWalker([txt1,txt2])
        box=urwid.ListBox(start_list)
        selection=urwid.LineBox(
                                box, title='', title_align='center',
                                tlcorner='┌', tline='─', lline='│',
                                trcorner='┐', blcorner='└', rline='│',
                                bline='─', brcorner='┘'
                                )
        selection_with_padding=urwid.Padding(selection,left=2,right=2)
        return selection_with_padding 
Example 14
Project: yTermPlayer   Author: TimeTraveller-San   File: ui.py    License: GNU General Public License v3.0 6 votes vote down vote up
def input_screen(self,button):
        #overlay second screen after start case1
        txt=urwid.Text("Enter the URL below: ")
        url_field=urwid.Edit(caption='', edit_text='', multiline=False,
                            align='left', wrap='space', allow_tab=False,
                            edit_pos=None, layout=None, mask=None)
        btn=urwid.Button("OK",user_data=None)
        url_button = urwid.AttrMap(btn,None,focus_map='reversed')
        urwid.connect_signal(btn, 'click', self.input_url,url_field)
        wid=urwid.Pile([txt,url_field,url_button])
        new=urwid.Filler(urwid.AttrMap(wid, None, focus_map=''))
        ok_screen_box=urwid.LineBox(
                                    new, title='', title_align='center',
                                    tlcorner='┌', tline='─', lline='│',
                                    trcorner='┐', blcorner='└', rline='│',
                                    bline='─', brcorner='┘'
                                    )
        self.top.original_widget=ok_screen_box 
Example 15
Project: yTermPlayer   Author: TimeTraveller-San   File: ui.py    License: GNU General Public License v3.0 6 votes vote down vote up
def load_list_screen(self,button):
        #overlay second screen after start case2
        txt=urwid.Text("Choose from the following:- ")
        _list=self.player_object.get_saved_lists()
        saved_list=[]
        for every_list in _list:
            b=urwid.Button(str(every_list).rstrip(),user_data=None)
            urwid.connect_signal(b, 'click', self.list_load)
            saved_list.append(urwid.AttrMap(b,None,focus_map='reversed'))
        box=urwid.ListBox(urwid.SimpleFocusListWalker(saved_list))
        list_box=urwid.LineBox(
                                box, title='', title_align='center',
                                tlcorner='┌', tline='─', lline='│',
                                trcorner='┐', blcorner='└', rline='│',
                                bline='─', brcorner='┘'
                                )
        list_box_padding=urwid.Padding(list_box,right=0,left=0)
        self.top.original_widget=list_box_padding 
Example 16
Project: TerminusBrowser   Author: wtheisen   File: historyFrame.py    License: 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 17
Project: TerminusBrowser   Author: wtheisen   File: watcherFrame.py    License: 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 18
Project: TerminusBrowser   Author: wtheisen   File: indexFrame.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def buildFrame(self):
        boardButtons = []
        for subreddit in self.subredditList:
            subreddit = '/r/' + subreddit if not subreddit.startswith('/r/') else subreddit
            if self.uFilter:
                if self.uFilter.lower() in subreddit.lower():
                    boardButtons.append(urwid.LineBox(urwid.AttrWrap(urwid.Button(subreddit, self.changeFrameBoard), 'center')))
            else:
                boardButtons.append(urwid.LineBox(urwid.AttrWrap(urwid.Button(subreddit, self.changeFrameBoard), 'center')))

        self.parsedItems = len(boardButtons)
        width = len(max(self.subredditList, key=len))
        buttonGrid = urwid.GridFlow(boardButtons, width + 9, 2, 2, 'center') # add 9 to width to account for widget padding
        listbox_content = [buttonGrid]

        return urwid.ListBox(urwid.SimpleListWalker(listbox_content)) 
Example 19
Project: wikicurses   Author: ids1024   File: main.py    License: MIT License 5 votes vote down vote up
def openOverlay(widget, title=None, height=('relative', 50), width=('relative', 50)):
    if widget.sizing() == {'flow'}:
        height = 'pack'
    box = urwid.LineBox(widget, title or widget.title)
    overlay = urwid.Overlay(box, mainwidget, 'center', width, 'middle', height)
    loop.widget = overlay 
Example 20
Project: ec2-gazua   Author: leejaycoke   File: gazua.py    License: MIT License 5 votes vote down vote up
def _init_widgets(self, names):
        self.names = names
        self.widgets = self._create_widgets()
        self.walker = ExpadableListWalker(self.widgets)
        self.listbox = ListBox(self.walker)
        self.view = LineBox(self.listbox, tlcorner='', tline='', lline='',
                            trcorner='', blcorner='', rline='│', bline='',
                            brcorner='') 
Example 21
Project: ec2-gazua   Author: leejaycoke   File: gazua.py    License: MIT License 5 votes vote down vote up
def _init_widgets(self, names):
        self.names = names
        self.widgets = self._create_widgets()
        self.walker = ExpadableListWalker(self.widgets)
        self.listbox = ListBox(self.walker)
        self.view = LineBox(self.listbox, tlcorner='', tline='', lline='',
                            trcorner='', blcorner='', rline='│', bline='',
                            brcorner='') 
Example 22
Project: vpngate-with-proxy   Author: Dragon2fly   File: ui_elements.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, key=None, value=''):
        self.chosen = 'ping' if value == '' else value
        self.trigger = key

        ping = MyButton("ping", self.item_callback)
        speed = MyButton("speed", self.item_callback)
        uptime = MyButton("up time", self.item_callback)
        score = MyButton("score", self.item_callback)

        default = {'ping': 0, 'speed': 1, 'up time': 2, 'score': 3}

        self.pile = urwid.Pile([ping, speed, uptime, score], focus_item=default[self.chosen])
        fill = urwid.LineBox(urwid.Filler(self.pile))
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg')) 
Example 23
Project: vpngate-with-proxy   Author: Dragon2fly   File: ui_elements.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, key=None, value=''):
        self.trigger = key
        info = urwid.Text("'ESC' to clear, leave blank or 'all' for all country and port", 'center')
        self.country = urwid.Edit(('attention', u' \N{BULLET} Country: '), edit_text=value[0], wrap='clip')
        self.port = urwid.Edit(('attention', u' \N{BULLET} Port   : '), edit_text=value[1], wrap='clip')
        self.score = urwid.Edit(('attention', u' \N{BULLET} Score >: '), edit_text=value[2], wrap='clip')
        exit_but = urwid.Padding(urwid.Button('OKay'.center(8), self.item_callback), 'center', 12)
        filter_ = [urwid.AttrMap(wid, None, 'popbgs') for wid in (self.country, self.port, self.score, exit_but)]

        self.pile = urwid.Pile([info]+filter_)
        fill = urwid.LineBox(urwid.Filler(self.pile))
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))

        self.chosen = value 
Example 24
Project: vpngate-with-proxy   Author: Dragon2fly   File: ui_elements.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, key=None, value=('', '')):
        self.trigger = key
        self.yn = value[0]
        self.yn_but = MyButton([('attention', 'Fix it: '), self.yn], self.on_change)
        self.input_dns = urwid.Edit(('attention', u' \N{BULLET} DNS   : '), edit_text=value[1], wrap='clip')
        exit_but = urwid.Padding(urwid.Button('OKay'.center(8), self.item_callback), 'center', 12)

        widgets = [self.yn_but] + [urwid.AttrMap(wid, None, 'popbgs') for wid in (self.input_dns, exit_but)]

        self.pile = urwid.Pile(widgets)
        fill = urwid.LineBox(urwid.Filler(self.pile))
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))

        self.chosen = value 
Example 25
Project: zulip-terminal   Author: zulip   File: ui.py    License: Apache License 2.0 5 votes vote down vote up
def message_view(self) -> Any:
        self.middle_column = MiddleColumnView(self, self.model, self.write_box,
                                              self.search_box)
        return urwid.LineBox(self.middle_column, title='Messages',
                             bline='', tline='━',
                             trcorner='│', tlcorner='│') 
Example 26
Project: zulip-terminal   Author: zulip   File: ui.py    License: Apache License 2.0 5 votes vote down vote up
def right_column_view(self) -> Any:
        self.users_view = RightColumnView(View.RIGHT_WIDTH, self)
        return urwid.LineBox(
            self.users_view, title="Users",
            tlcorner='━', tline='━', lline='',
            trcorner='━', blcorner='─', rline='',
            bline='', brcorner=''
        ) 
Example 27
Project: zulip-terminal   Author: zulip   File: core.py    License: Apache License 2.0 5 votes vote down vote up
def show_pop_up(self, to_show: Any) -> None:
        double_lines = dict(tlcorner='╔', tline='═', trcorner='╗',
                            rline='║', lline='║',
                            blcorner='╚', bline='═', brcorner='╝')
        self.loop.widget = urwid.Overlay(
            urwid.LineBox(to_show,
                          to_show.title,
                          **double_lines),
            self.view,
            align='center',
            valign='middle',
            # +2 to both of the following, due to LineBox
            width=to_show.width + 2,
            height=to_show.height + 2,
        ) 
Example 28
Project: zulip-terminal   Author: zulip   File: views.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, streams_btn_list: List[Any], view: Any) -> None:
        self.view = view
        self.log = urwid.SimpleFocusListWalker(streams_btn_list)
        self.streams_btn_list = streams_btn_list
        self.focus_index_before_search = 0
        list_box = urwid.ListBox(self.log)
        self.stream_search_box = PanelSearchBox(self,
                                                'SEARCH_STREAMS',
                                                self.update_streams)
        super().__init__(list_box, header=urwid.LineBox(
            self.stream_search_box, tlcorner='─', tline='', lline='',
            trcorner='─', blcorner='─', rline='',
            bline='─', brcorner='─'
        ))
        self.search_lock = threading.Lock() 
Example 29
Project: zulip-terminal   Author: zulip   File: views.py    License: Apache License 2.0 5 votes vote down vote up
def __init__(self, topics_btn_list: List[Any], view: Any,
                 stream_button: Any) -> None:
        self.view = view
        self.log = urwid.SimpleFocusListWalker(topics_btn_list)
        self.topics_btn_list = topics_btn_list
        self.stream_button = stream_button
        self.focus_index_before_search = 0
        self.list_box = urwid.ListBox(self.log)
        self.topic_search_box = PanelSearchBox(self,
                                               'SEARCH_TOPICS',
                                               self.update_topics)
        self.header_list = urwid.Pile([self.stream_button,
                                       urwid.Divider('─'),
                                       self.topic_search_box])
        super().__init__(self.list_box, header=urwid.LineBox(
            self.header_list, tlcorner='─', tline='', lline='',
            trcorner='─', blcorner='─', rline='',
            bline='─', brcorner='─'
        ))
        self.search_lock = threading.Lock() 
Example 30
Project: zulip-terminal   Author: zulip   File: views.py    License: Apache License 2.0 5 votes vote down vote up
def streams_view(self) -> Any:
        streams_btn_list = [
                StreamButton(
                    stream,
                    controller=self.controller,
                    view=self.view,
                    width=self.width,
                    count=self.model.unread_counts['streams'].get(stream[1], 0)
                ) for stream in self.view.pinned_streams]

        if len(streams_btn_list):
            unpinned_divider = urwid.Divider("-")

            # FIXME Necessary since the divider is treated as a StreamButton
            # NOTE: This is specifically for stream search to work correctly
            unpinned_divider.stream_id = -1
            unpinned_divider.stream_name = ''

            streams_btn_list += [unpinned_divider]

        streams_btn_list += [
                StreamButton(
                    stream,
                    controller=self.controller,
                    view=self.view,
                    width=self.width,
                    count=self.model.unread_counts['streams'].get(stream[1], 0)
                ) for stream in self.view.unpinned_streams]

        self.view.stream_id_to_button = {stream.stream_id: stream
                                         for stream in streams_btn_list
                                         if hasattr(stream, 'stream_id')}

        self.view.stream_w = StreamsView(streams_btn_list, self.view)
        w = urwid.LineBox(
            self.view.stream_w, title="Streams",
            tlcorner='━', tline='━', lline='',
            trcorner='━', blcorner='', rline='',
            bline='', brcorner='─'
            )
        return w