當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。