当前位置: 首页>>代码示例>>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;未经允许,请勿转载。