当前位置: 首页>>代码示例>>Python>>正文


Python urwid.emit_signal方法代码示例

本文整理汇总了Python中urwid.emit_signal方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.emit_signal方法的具体用法?Python urwid.emit_signal怎么用?Python urwid.emit_signal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urwid的用法示例。


在下文中一共展示了urwid.emit_signal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _execute_on_selected

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def _execute_on_selected(self, p_cmd_str, p_execute_signal):
        """
        Executes command specified by p_cmd_str on selected todo item.

        p_cmd_str should be a string with one replacement field ('{}') which
        will be substituted by id of the selected todo item.

        p_execute_signal is the signal name passed to the main loop. It should
        be one of 'execute_command' or 'execute_command_silent'.
        """
        try:
            todo = self.listbox.focus.todo
            todo_id = str(self.view.todolist.number(todo))

            urwid.emit_signal(self, p_execute_signal, p_cmd_str, todo_id)

            # force screen redraw after editing
            if p_cmd_str.startswith('edit'):
                urwid.emit_signal(self, 'refresh')
        except AttributeError:
            # No todo item selected
            pass 
开发者ID:bram85,项目名称:topydo,代码行数:24,代码来源:TodoListWidget.py

示例2: resolve_action

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def resolve_action(self, p_action_str, p_size=None):
        """
        Checks whether action specified in p_action_str is "built-in" or
        contains topydo command (i.e. starts with 'cmd') and forwards it to
        proper executing methods.

        p_size should be specified for some of the builtin actions like 'up' or
        'home' as they can interact with urwid.ListBox.keypress or
        urwid.ListBox.calculate_visible.
        """
        if p_action_str.startswith(('cmd ', 'cmdv ')):
            prefix, cmd = p_action_str.split(' ', 1)
            execute_signal = get_execute_signal(prefix)

            if '{}' in cmd:
                self._execute_on_selected(cmd, execute_signal)
            else:
                urwid.emit_signal(self, execute_signal, cmd)
        else:
            self.execute_builtin_action(p_action_str, p_size) 
开发者ID:bram85,项目名称:topydo,代码行数:22,代码来源:TodoListWidget.py

示例3: handle_floating_date

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def handle_floating_date(self, size):
        # No messages, no date
        if not self.focus:
            urwid.emit_signal(self, 'set_date', None)
            return
        middle, top, _ = self.calculate_visible(size, self.focus)
        row_offset, widget, focus_position, _, _ = middle
        index = focus_position - row_offset + top[0]
        all_before = self.body[:index]
        all_before.reverse()
        text_divider = None
        for row in all_before:
            if isinstance(row, TextDivider):
                text_divider = row
                break
        urwid.emit_signal(self, 'set_date', text_divider) 
开发者ID:haskellcamargo,项目名称:sclack,代码行数:18,代码来源:components.py

示例4: keypress

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def keypress(self, size, key):
        reserved_keys = ('up', 'down', 'page up', 'page down')
        if key in reserved_keys:
            return super(SetSnoozeWidget, self).keypress(size, key)
        elif key == 'enter':
            focus = self.snooze_time_list.body.get_focus()
            if focus[0]:
                urwid.emit_signal(self, 'set_snooze_time', focus[0].id)
                urwid.emit_signal(self, 'close_set_snooze')
                return True
        elif key == 'esc':
            focus = self.snooze_time_list.body.get_focus()
            if focus[0]:
                urwid.emit_signal(self, 'close_set_snooze')
                return True

        self.header.keypress((size[0],), key) 
开发者ID:haskellcamargo,项目名称:sclack,代码行数:19,代码来源:set_snooze.py

示例5: keypress

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def keypress(self, size, key):
        if key == "enter":
            command = self._edit_box.edit_text

            if self._prompt_mode:
                # We're in prompt mode, return the value
                # to the queue which unblocks the prompt method.
                self._prompt_queue.put(command)
                self._prompt_mode = False
                self.clear()
            else:
                # Normal mode, call listeners.
                urwid.emit_signal(self, "line_entered", command)

            self._edit_box.edit_text = ""
        else:
            urwid.Edit.keypress(self._edit_box, size, key) 
开发者ID:Marten4n6,项目名称:EvilOSX,代码行数:19,代码来源:cli.py

示例6: keypress

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def keypress(self, p_size, p_key):
        if p_key == 'enter' or p_key == 'q' or p_key == 'esc':
            urwid.emit_signal(self, 'close')

        # don't return the key, 'enter', 'escape', 'q' or ':' are your only
        # escape. ':' will reenter to the cmdline.
        elif p_key == ':':
            urwid.emit_signal(self, 'close', True) 
开发者ID:bram85,项目名称:topydo,代码行数:10,代码来源:ConsoleWidget.py

示例7: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def __init__(self, p_todolist):
        self._todolist = p_todolist

        self.titleedit = urwid.Edit("Title: ", "")
        self.sortedit = urwid.Edit("Sort expression: ", "")
        self.groupedit = urwid.Edit("Group expression: ", "")
        self.filteredit = urwid.Edit("Filter expression: ", "")

        radiogroup = []
        self.relevantradio = urwid.RadioButton(radiogroup, "Only show relevant todo items", True)
        self.allradio = urwid.RadioButton(radiogroup, "Show all todo items")

        self.pile = urwid.Pile([
            self.filteredit,
            self.titleedit,
            self.sortedit,
            self.groupedit,
            self.relevantradio,
            self.allradio,
            urwid.Button("Save", lambda _: urwid.emit_signal(self, 'save')),
            urwid.Button("Cancel", lambda _: self.close()),
        ])

        self.reset()

        super().__init__(self.pile)

        urwid.register_signal(ViewWidget, ['save', 'close']) 
开发者ID:bram85,项目名称:topydo,代码行数:30,代码来源:ViewWidget.py

示例8: close

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def close(self):
        urwid.emit_signal(self, 'close') 
开发者ID:bram85,项目名称:topydo,代码行数:4,代码来源:ViewWidget.py

示例9: keystate

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def keystate(self, p_keystate):
        self._keystate = p_keystate
        keystate_to_show = p_keystate if p_keystate else ''
        urwid.emit_signal(self, 'show_keystate', keystate_to_show) 
开发者ID:bram85,项目名称:topydo,代码行数:6,代码来源:TodoListWidget.py

示例10: _mark_all

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def _mark_all(self):
        for todo in self.listbox.body:
            if isinstance(todo, TodoWidget):
                todo_id = str(self.view.todolist.number(todo.todo))
                urwid.emit_signal(self, 'toggle_mark', todo_id, 'mark')
                todo.mark() 
开发者ID:bram85,项目名称:topydo,代码行数:8,代码来源:TodoListWidget.py

示例11: _add_pending_action

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def _add_pending_action(self, p_action, p_size):
        """
        Creates action waiting for execution and forwards it to the mainloop.
        """
        def generate_callback():
            def callback(*args):
                self.resolve_action(p_action, p_size)
                self.keystate = None

            return callback

        urwid.emit_signal(self, 'add_pending_action', generate_callback()) 
开发者ID:bram85,项目名称:topydo,代码行数:14,代码来源:TodoListWidget.py

示例12: _blur

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def _blur(self):
        self.clear()
        urwid.emit_signal(self, 'blur') 
开发者ID:bram85,项目名称:topydo,代码行数:5,代码来源:CommandLineWidget.py

示例13: _emit_command

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def _emit_command(self):
        if len(self.edit_text) > 0:
            urwid.emit_signal(self, 'execute_command', self.edit_text)
            self._save_to_history()
            self.clear() 
开发者ID:bram85,项目名称:topydo,代码行数:7,代码来源:CommandLineWidget.py

示例14: completion_mode

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def completion_mode(self, p_enable):
        if p_enable is True:
            urwid.emit_signal(self, 'show_completions')
        elif p_enable is False:
            self._surrounding_text = None
            if self.completion_mode:
                self.completion_box.clear()
                urwid.emit_signal(self, 'hide_completions') 
开发者ID:bram85,项目名称:topydo,代码行数:10,代码来源:CommandLineWidget.py

示例15: mouse_event

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import emit_signal [as 别名]
def mouse_event(self, p_size, p_event, p_button, p_col, p_row, p_focus):
        if self.focus_position != 2:
            urwid.emit_signal(self, 'blur_console')

        return super().mouse_event(p_size, p_event, p_button, p_col, p_row, p_focus)  # pylint: disable=E1102 
开发者ID:bram85,项目名称:topydo,代码行数:7,代码来源:Main.py


注:本文中的urwid.emit_signal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。