(self, event)
Override Qt method to process keypress.
Override Qt method to process keypress.
Override Qt method to process keypress .
def keyPressEvent(self, event):
        """Override Qt method to process keypress."""
        # pylint: disable=too-many-branches
        text, key = event.text(), event.key()
        alt = event.modifiers() & Qt.AltModifier
        shift = event.modifiers() & Qt.ShiftModifier
        ctrl = event.modifiers() & Qt.ControlModifier
        altgr = event.modifiers() and (key == Qt.Key_AltGr)
        # Needed to properly handle Neo2 and other keyboard layouts
        # See spyder-ide/spyder#11293
        neo2_level4 = (key == 0)  # AltGr (ISO_Level5_Shift) in Neo2 on Linux
        modifier = shift or ctrl or alt or altgr or neo2_level4
        if key in (Qt.Key_Return, Qt.Key_Enter, Qt.Key_Tab):
            # Check that what was selected can be selected,
            # otherwise timing issues
            item = self.currentItem()
            if item is None:
                item = self.item(0)

            if self.is_up_to_date(item=item):
                self.item_selected(item=item)
            else:
                self.hide()
                self.textedit.keyPressEvent(event)
        elif key == Qt.Key_Escape:
            self.hide()
        elif key in (Qt.Key_Left, Qt.Key_Right) or text in ('.', ':'):
            self.hide()
            self.textedit.keyPressEvent(event)
        elif key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown,
                     Qt.Key_Home, Qt.Key_End) and not modifier:
            if key == Qt.Key_Up and self.currentRow() == 0:
                self.setCurrentRow(self.count() - 1)
            elif key == Qt.Key_Down and self.currentRow() == self.count() - 1:
                self.setCurrentRow(0)
            else:
                QListWidget.keyPressEvent(self, event)
        elif len(text) > 0 or key == Qt.Key_Backspace:
            self.textedit.keyPressEvent(event)
            self.update_current()
        elif modifier:
            self.textedit.keyPressEvent(event)
        else:
            self.hide()
            QListWidget.keyPressEvent(self, event)
def keyPressEvent ( self , event ) : # pylint: disable=too-many-branches text , key = event . text ( ) , event . key ( ) alt = event . modifiers ( ) & Qt . AltModifier shift = event . modifiers ( ) & Qt . ShiftModifier ctrl = event . modifiers ( ) & Qt . ControlModifier altgr = event . modifiers ( ) and ( key == Qt . Key_AltGr ) # Needed to properly handle Neo2 and other keyboard layouts # See spyder-ide/spyder#11293 neo2_level4 = ( key == 0 ) # AltGr (ISO_Level5_Shift) in Neo2 on Linux modifier = shift or ctrl or alt or altgr or neo2_level4 if key in ( Qt . Key_Return , Qt . Key_Enter , Qt . Key_Tab ) : # Check that what was selected can be selected, # otherwise timing issues item = self . currentItem ( ) if item is None : item = self . item ( 0 ) if self . is_up_to_date ( item = item ) : self . item_selected ( item = item ) else : self . hide ( ) self . textedit . keyPressEvent ( event ) elif key == Qt . Key_Escape : self . hide ( ) elif key in ( Qt . Key_Left , Qt . Key_Right ) or text in ( '.' , ':' ) : self . hide ( ) self . textedit . keyPressEvent ( event ) elif key in ( Qt . Key_Up , Qt . Key_Down , Qt . Key_PageUp , Qt . Key_PageDown , Qt . Key_Home , Qt . Key_End ) and not modifier : if key == Qt . Key_Up and self . currentRow ( ) == 0 : self . setCurrentRow ( self . count ( ) - 1 ) elif key == Qt . Key_Down and self . currentRow ( ) == self . count ( ) - 1 : self . setCurrentRow ( 0 ) else : QListWidget . keyPressEvent ( self , event ) elif len ( text ) > 0 or key == Qt . Key_Backspace : self . textedit . keyPressEvent ( event ) self . update_current ( ) elif modifier : self . textedit . keyPressEvent ( event ) else : self . hide ( ) QListWidget . keyPressEvent ( self , event )