Python urwid 模块,emit_signal() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用urwid.emit_signal()

项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def keypress(self, size, key):
        """Handle all keyboard shortcuts for the market menu"""
        if key in self.keypress_map:
            # Open up the order dialog to buy sell this item
            commodity = self.keypress_map[key]
            self.pubpen.publish(self.order_info_event, commodity,
                                self.auxiliary_cols[self.price_col_idx].data_map[commodity],
                                self.location)
            urwid.emit_signal(self, self.signals[1])
        elif key in ('left', 'right'):
            # Ignore keys that might move focus to a widget to the side
            return
        elif key in ('up', 'down', 'page up', 'page down'):
            # First let the children handle the change in focus...
            super().keypress(size, key)  #pylint: disable=not-callable
            # Then highlight the same entry in other columns
            self._highlight_focused_line()
        else:
            super().keypress(size, key)  #pylint: disable=not-callable
        return key
项目:Drogo    作者:csrgxtu    | 项目源码 | 文件源码
def keypress(self, size, key):
        if key=='enter':
            line=self.edit_text.strip()
            if line:
                urwid.emit_signal(self,'line_entered', line)
                self.history.append(line)
            self._history_index=len(self.history)
            self.edit_text=u''
        if key=='up':

            self._history_index-=1
            if self._history_index< 0:
                self._history_index= 0
            else:
                self.edit_text=self.history[self._history_index]
        if key=='down':
            self._history_index+=1
            if self._history_index>=len(self.history):
                self._history_index=len(self.history)
                self.edit_text=u''
            else:
                self.edit_text=self.history[self._history_index]
        else:
            urwid.Edit.keypress(self, size, key)
项目:Drogo    作者:csrgxtu    | 项目源码 | 文件源码
def keypress(self, size, key):
        if key=='enter':
            line=self.edit_text.strip()
            if line:
                urwid.emit_signal(self,'line_entered', line)
                self.history.append(line)
            self._history_index=len(self.history)
            self.edit_text=u''
        if key=='up':

            self._history_index-=1
            if self._history_index< 0:
                self._history_index= 0
            else:
                self.edit_text=self.history[self._history_index]
        if key=='down':
            self._history_index+=1
            if self._history_index>=len(self.history):
                self._history_index=len(self.history)
                self.edit_text=u''
            else:
                self.edit_text=self.history[self._history_index]
        else:
            urwid.Edit.keypress(self, size, key)
项目:PyAlertMe    作者:jamesleesaunders    | 项目源码 | 文件源码
def keypress(self, size, key):
        if key == 'enter':
            line = self.edit_text.strip()
            if line:
                urwid.emit_signal(self, 'line_entered', line)
                self.history.append(line)
            self._history_index = len(self.history)
            self.edit_text = u''
        if key == 'up':

            self._history_index -= 1
            if self._history_index < 0:
                self._history_index = 0
            else:
                self.edit_text = self.history[self._history_index]
        if key == 'down':
            self._history_index += 1
            if self._history_index >= len(self.history):
                self._history_index = len(self.history)
                self.edit_text = u''
            else:
                self.edit_text = self.history[self._history_index]
        else:
            urwid.Edit.keypress(self, size, key)
项目:selecta    作者:vindolin    | 项目源码 | 文件源码
def keypress(self, size, key):
        if key == 'enter':
            urwid.emit_signal(self, 'done', self.get_edit_text())
            return
        elif key == 'esc':
            urwid.emit_signal(self, 'done', None)
            return
        elif key == 'tab':
            urwid.emit_signal(self, 'toggle_case_modifier')
            urwid.emit_signal(self, 'change', self, self.get_edit_text())
            return
        elif key == 'ctrl r':
            urwid.emit_signal(self, 'toggle_regexp_modifier')
            urwid.emit_signal(self, 'change', self, self.get_edit_text())
            return
        elif key == 'down':
            urwid.emit_signal(self, 'done', None)
            return

        urwid.Edit.keypress(self, size, key)
项目:doubanfm-py    作者:nekocode    | 项目源码 | 文件源码
def keypress(self, size, key):
        if key in ('up', 'down', 'page up', 'page down', 'enter', ' ', 'j', 'k'):
            return super(SongListBox, self).keypress(size, key)

        if key in ('q', 'Q', 'esc'):
            # ??????
            urwid.emit_signal(self, 'exit')

        if key in ('s', 'S'):
            # ????
            urwid.emit_signal(self, 'stop')

        if key in ('left', 'right'):
            # ?????
            urwid.emit_signal(self, 'next_song')

        if key in ('m', 'M'):
            # ????
            urwid.emit_signal(self, 'change_mode')
项目:GitChat    作者:shubhodeep9    | 项目源码 | 文件源码
def keypress(self, size, key):
        if key == 'enter':
            line = self.edit_text.strip()
            if line:
                urwid.emit_signal(self, 'line_entered', line)
                self.history.append(line)
            self._history_index = len(self.history)
            self.edit_text = u''
        if key == 'up':

            self._history_index -= 1
            if self._history_index < 0:
                self._history_index = 0
            else:
                self.edit_text = self.history[self._history_index]
        if key == 'down':
            self._history_index += 1
            if self._history_index >= len(self.history):
                self._history_index = len(self.history)
                self.edit_text = u''
            else:
                self.edit_text = self.history[self._history_index]
        else:
            urwid.Edit.keypress(self, size, key)
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def handle_commodity_select(self, commodity, *args):
        """
        Create a buy/sell dialog when the commodity is selected

        :arg commodity: The name of the commodity selected
        """
        # If the user selected the line via the mouse, then we need to sync
        # the highlighted line
        self.commodity.set_focus(self.commodity_col.data_map[commodity])
        self._highlight_focused_line()

        self.pubpen.publish(self.order_info_event, commodity,
                            self.auxiliary_cols[self.price_col_idx].data_map[commodity],
                            self.location)
        urwid.emit_signal(self, self.signals[1])
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def keypress(self, *args):
        """Any interaction with the widget moves on to the next screen"""
        urwid.emit_signal(self, 'close_title_card')
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def handle_transaction_finalized(self, *args, **kwargs):
        """
        Clear the transation dialog state when we are told the transaction is finished.

        This cleans up the event notifications and closes the dialog.
        """
        self.finalize()

        # Close the dialog
        urwid.emit_signal(self, self.signals[0])
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def handle_new_location(self, *args):
        """Got a valid new location so we can close this window"""
        self.pubpen.unsubscribe(self._ship_moved_sub_id)
        self._ship_moved_sub_id = None
        urwid.emit_signal(self, 'close_travel_menu')

    # urwid event handlers
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def logged_in(self, username):
        """Tell the main window that we've logged in"""
        urwid.emit_signal(self, 'logged_in')
项目:papis    作者:alejandrogallo    | 项目源码 | 文件源码
def keypress(self, size, key):
        if key == 'enter':
            urwid.emit_signal(self, 'done', self.get_edit_text())
            return
        elif key == 'esc':
            urwid.emit_signal(self, 'done', None)
            return

        urwid.Edit.keypress(self, size, key)
项目:my_ros_tools    作者:groundmelon    | 项目源码 | 文件源码
def on_finish(self, widget):
        urwid.emit_signal(self, 'done', self, self.get_edit_text())
项目:my_ros_tools    作者:groundmelon    | 项目源码 | 文件源码
def on_close(self, widget, s):
        urwid.emit_signal(self, "close", self, s)
项目:selecta    作者:vindolin    | 项目源码 | 文件源码
def render(self, size, focus):
        if size != self.last_size:
            self.last_size = size
            urwid.emit_signal(self, 'resize', size)
        return urwid.ListBox.render(self, size, focus)