當前位置: 首頁>>代碼示例>>Python>>正文


Python urwid.SimpleFocusListWalker方法代碼示例

本文整理匯總了Python中urwid.SimpleFocusListWalker方法的典型用法代碼示例。如果您正苦於以下問題:Python urwid.SimpleFocusListWalker方法的具體用法?Python urwid.SimpleFocusListWalker怎麽用?Python urwid.SimpleFocusListWalker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urwid的用法示例。


在下文中一共展示了urwid.SimpleFocusListWalker方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def __init__(self):
        def selectButton(radio_button, new_state, parameter):
            if new_state:
                closeOverlay()
                self._select(parameter)

        super().__init__(urwid.SimpleFocusListWalker([]))
        buttons = []
        for i, item in enumerate(self._items()):
            if isinstance(item, urwid.Widget):
                self.body.append(item)
                continue
            elif isinstance(item, tuple):
                name, selected, parameter = item
            else:
                parameter = name = item
                selected = False
            self.body.append(urwid.RadioButton(buttons, name, selected,
                                               selectButton, parameter))
            if selected:
                self.set_focus(i) 
開發者ID:ids1024,項目名稱:wikicurses,代碼行數:23,代碼來源:main.py

示例2: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
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() 
開發者ID:zulip,項目名稱:zulip-terminal,代碼行數:22,代碼來源:views.py

示例3: quote_view_action

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def quote_view_action(self, button, message):
        """
        Callback function to view a quote from the message object menu.
        """
        widget = OptionsMenu(
            ActionBox(urwid.SimpleFocusListWalker(self.make_message_body(message))),
            **self.frame_theme(">>%d" % message["post_id"])
        )

        self.loop.widget = urwid.Overlay(
            widget, self.loop.widget,
            align=("relative", 50),
            valign=("relative", 50),
            width=("relative", 98),
            height=("relative", 60)
        ) 
開發者ID:bbj-dev,項目名稱:bbj,代碼行數:18,代碼來源:main.py

示例4: formatting_help

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def formatting_help(self, *_):
        """
        Pops a help window for formatting directives.
        """
        # we can "recycle" the server's formatting abilities to
        # use the same syntax for the help text itself
        message = network.fake_message(
            "\n\n".join(format_help), format="sequential")

        widget = OptionsMenu(
            urwid.ListBox(urwid.SimpleFocusListWalker(app.make_message_body(message, True))),
            **self.frame_theme("Formatting Help")
        )

        va = 5 if self.window_split else 50
        vh = 45 if self.window_split else 75
        app.loop.widget = urwid.Overlay(
            widget, app.loop.widget,
            align=("relative", 50),
            valign=("relative", va),
            width=self.prefs["max_text_width"],
            height=("relative", vh)
        ) 
開發者ID:bbj-dev,項目名稱:bbj,代碼行數:25,代碼來源:main.py

示例5: set_escape_key

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def set_escape_key(self, button, args):
        mode = args[0]
        widget = OptionsMenu(
            urwid.ListBox(urwid.SimpleFocusListWalker([
                urwid.Text("Press Enter when done"),
                urwid.AttrMap(KeyPrompt(
                    self.prefs["edit_escapes"][mode],
                    self.save_escape_key,
                    [mode]
                ), "opt_prompt")])),
            **self.frame_theme("Set key for " + mode)
        )

        app.loop.widget = urwid.Overlay(
            urwid.AttrMap(widget, "30"),
            app.loop.widget,
            align=("relative", 50),
            valign=("relative", 50),
            width=25, height=5
        ) 
開發者ID:bbj-dev,項目名稱:bbj,代碼行數:22,代碼來源:main.py

示例6: test_evaluated_key_does_not_replace_original_key

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def test_evaluated_key_does_not_replace_original_key(self):
        # Create a list of widgets that translate 'j' to 'down' in their
        # keypress() methods.
        lst_contents = [self.mk_widget(urwid.Text, str(i), context='item')
                        for i in range(1, 10)]
        self.keymap.bind('j', context='item', action=Key('down'))

        # Create ListBox with separate key context.  If the ListBox gets to
        # handle 'j', it just checks a mark we can look for.
        lst_widget = self.mk_widget(urwid.ListBox, urwid.SimpleFocusListWalker(lst_contents), context='list')
        lst_got_j = FakeAction()
        self.keymap.bind('j', context='list', action=lst_got_j)

        # Make sure everything works regularly
        size = (3, 3)
        self.assert_lines(lst_widget, size, exp_lines=('1  ', '2  ', '3  '), exp_focus_pos=0)
        lst_widget.keypress(size, 'down')
        self.assert_lines(lst_widget, size, exp_lines=('1  ', '2  ', '3  '), exp_focus_pos=1)

        # Do the actual test: Pressing 'j' should pass 'j' to the focused item,
        # which evaluates it to 'down'.  But the list widget must get 'j'.
        lst_widget.keypress(size, 'j')
        self.assert_lines(lst_widget, size, exp_lines=('1  ', '2  ', '3  '), exp_focus_pos=1)
        self.assertEqual(lst_got_j.callnum, 1) 
開發者ID:rndusr,項目名稱:stig,代碼行數:26,代碼來源:keymap_test.py

示例7: start_screen

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
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 
開發者ID:TimeTraveller-San,項目名稱:yTermPlayer,代碼行數:20,代碼來源:ui.py

示例8: load_list_screen

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
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 
開發者ID:TimeTraveller-San,項目名稱:yTermPlayer,代碼行數:20,代碼來源:ui.py

示例9: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def __init__(self, coroutine_queue, conversation, on_cancel, on_save,
                 keybindings):
        self._coroutine_queue = coroutine_queue
        self._conversation = conversation
        edit = urwid.Edit(edit_text=get_conv_name(conversation))
        items = [
            urwid.Text('Rename conversation:'),
            edit,
            urwid.Button(
                'Save',
                on_press=lambda _: self._rename(edit.edit_text, on_save)
            ),
            urwid.Button('Cancel', on_press=lambda _: on_cancel()),
        ]
        list_walker = urwid.SimpleFocusListWalker(items)
        list_box = ListBox(keybindings, list_walker)
        super().__init__(list_box) 
開發者ID:tdryer,項目名稱:hangups,代碼行數:19,代碼來源:__main__.py

示例10: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def __init__(self, config):
        self.config = config

        self.descr_width  = 26
        self.config_width = 29

        lines = []
        lines.extend(self.create_kb_help_lines('Keybinds Common', 'common'))
        lines.extend(self.create_kb_help_lines('Keybinds Note List', 'titles'))
        lines.extend(self.create_kb_help_lines('Keybinds Note Content', 'notes'))
        lines.extend(self.create_config_help_lines())
        lines.extend(self.create_color_help_lines())
        lines.append(urwid.Text(('help_header', '')))

        super(ViewHelp, self).__init__(urwid.SimpleFocusListWalker(lines)) 
開發者ID:insanum,項目名稱:sncli,代碼行數:17,代碼來源:view_help.py

示例11: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def __init__(self, config):
        self.config = config
        super(ViewLog, self).__init__(urwid.SimpleFocusListWalker([])) 
開發者ID:insanum,項目名稱:sncli,代碼行數:5,代碼來源:view_log.py

示例12: update_log

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def update_log(self):
        lines = []
        f = open(self.config.logfile)
        for line in f:
            lines.append(
                urwid.AttrMap(urwid.Text(line.rstrip()),
                                'note_content',
                                'note_content_focus'))
        f.close()
        if self.config.get_config('log_reversed') == 'yes':
            lines.reverse()
        self.body[:] = urwid.SimpleFocusListWalker(lines)
        self.focus_position = 0 
開發者ID:insanum,項目名稱:sncli,代碼行數:15,代碼來源:view_log.py

示例13: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def __init__(self, config, args):
        self.config = config
        self.ndb = args['ndb']
        self.key = args['key']
        self.log = args['log']
        self.search_string = ''
        self.search_mode = 'gstyle'
        self.search_direction = ''
        self.note = self.ndb.get_note(self.key) if self.key else None
        self.old_note = None
        self.tabstop = int(self.config.get_config('tabstop'))
        self.clipboard = Clipboard()
        super(ViewNote, self).__init__(
                  urwid.SimpleFocusListWalker(self.get_note_content_as_list())) 
開發者ID:insanum,項目名稱:sncli,代碼行數:16,代碼來源:view_note.py

示例14: update_note_view

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def update_note_view(self, key=None, version=None):
        if key: # setting a new note
            self.key      = key
            self.note     = self.ndb.get_note(self.key)
            self.old_note = None

        if self.key and version:
            # verify version is within range
            if int(version) <= 0 or int(version) >= self.note['version'] + 1:
                self.log('Version v{0} is unavailable (key={1})'.
                         format(version, self.key))
                return

        if (not version and self.old_note) or \
           (self.key and version and version == self.note['version']):
            self.log('Displaying latest version v{0} of note (key={1})'.
                     format(self.note['version'], self.key))
            self.old_note = None
        elif self.key and version:
            # get a previous version of the note
            self.log('Fetching version v{0} of note (key={1})'.
                     format(version, self.key))
            version_note = self.ndb.get_note_version(self.key, version)
            if not version_note:
                self.log('Failed to get version v{0} of note (key={1})'.
                         format(version, self.key))
                # don't do anything, keep current note/version
            else:
                self.old_note = version_note

        self.body[:] = \
            urwid.SimpleFocusListWalker(self.get_note_content_as_list())
        if not self.search_string:
            self.focus_position = 0 
開發者ID:insanum,項目名稱:sncli,代碼行數:36,代碼來源:view_note.py

示例15: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import SimpleFocusListWalker [as 別名]
def __init__(self, config, args):
        self.config = config
        self.ndb = args['ndb']
        self.search_string = args['search_string']
        self.log = args['log']
        self.note_list, self.match_regex, self.all_notes_cnt = \
            self.ndb.filter_notes(self.search_string, sort_mode=self.config.get_config('sort_mode'))
        super(ViewTitles, self).__init__(
                  urwid.SimpleFocusListWalker(self.get_note_titles())) 
開發者ID:insanum,項目名稱:sncli,代碼行數:11,代碼來源:view_titles.py


注:本文中的urwid.SimpleFocusListWalker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。