Python PyQt5.QtCore.Qt 模块,Key_Return() 实例源码

我们从Python开源项目中,提取了以下34个代码示例,用于说明如何使用PyQt5.QtCore.Qt.Key_Return()

项目:QtPropertyBrowserV2.6-for-pyqt5    作者:theall    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() in [Qt.Key_Return, Qt.Key_Enter, Qt.Key_Space]:## Trigger Edit
            if (not self.m_editorPrivate.editedItem()):
                item = self.currentItem()
                if item:
                    if (item.columnCount() >= 2 and ((item.flags() & (Qt.ItemIsEditable | Qt.ItemIsEnabled)) == (Qt.ItemIsEditable | Qt.ItemIsEnabled))):
                        event.accept()
                        ## If the current position is at column 0, move to 1.
                        index = self.currentIndex()
                        if (index.column() == 0):
                            index = index.sibling(index.row(), 1)
                            self.setCurrentIndex(index)
                        self.edit(index)
                        return

        super(QtPropertyEditorView, self).keyPressEvent(event)
项目:QtPropertyBrowserV2.6-for-pyqt5    作者:theall    | 项目源码 | 文件源码
def handleKeyEvent(self, e):
        key = e.key()
        if key in [Qt.Key_Control, Qt.Key_Shift, Qt.Key_Meta, Qt.Key_Alt, Qt.Key_Super_L, Qt.Key_Return]:
            return

        text = e.text()
        if (len(text) != 1):
            return

        c = text[0]
        if (not c.isprintable()):
            return

        if (self.m_value == c):
            return

        self.m_value = c
        if self.m_value=='':
            s = ''
        else:
            s = str(self.m_value)
        self.m_lineEdit.setText(s)
        e.accept()
        self.valueChangedSignal.emit(self.m_value)
项目:QtPropertyBrowserV2.6-for-pyqt5    作者:theall    | 项目源码 | 文件源码
def eventFilter(self, obj, ev):
        if (obj == self.m_button):
            k = ev.type()
            if k in [QEvent.KeyPress, QEvent.KeyRelease]:# Prevent the QToolButton from handling Enter/Escape meant control the delegate
                x = ev.key()
                if x in [Qt.Key_Escape, Qt.Key_Enter, Qt.Key_Return]:
                    ev.ignore()
                    return True

        return super(QtColorEditWidget, self).eventFilter(obj, ev)
项目:mpvQC    作者:Frechdachs    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        pressedkey = event.key()
        if ((pressedkey == Qt.Key_Up or pressedkey == Qt.Key_Down)
                and int(app.keyboardModifiers()) == Qt.NoModifier):
            super(CommentListView, self).keyPressEvent(event)
        elif pressedkey == Qt.Key_Delete:
            deleteSelection()
            event.accept()
        elif pressedkey == Qt.Key_Enter or pressedkey == Qt.Key_Return:
            editSelection()
            event.accept()
        elif pressedkey == Qt.Key_C and int(app.keyboardModifiers()) == Qt.CTRL:
            copySelection()
            event.accept()
        else:
            event.ignore()
项目:pyqt5    作者:yurisnm    | 项目源码 | 文件源码
def set_up_keyboard_symbols_keys(self):
        row_1 = [Qt.Key_BracketLeft, Qt.Key_BracketRight, Qt.Key_BraceLeft,
                 Qt.Key_BraceRight, Qt.Key_Aring, Qt.Key_Percent,
                 Qt.Key_Dead_Circumflex, Qt.Key_Asterisk, Qt.Key_Plus,
                 Qt.Key_Equal, Qt.Key_Backspace]

        row_2 = [Qt.Key_Underscore, Qt.Key_Backslash, Qt.Key_Aring,
                 Qt.Key_Dead_Tilde, Qt.Key_Less, Qt.Key_Greater,
                 Qt.Key_Aring, Qt.Key_Aring, Qt.Key_Aring, Qt.Key_Return]

        row_3 = [Qt.Key_Aring, Qt.Key_Period, Qt.Key_Comma, Qt.Key_Question,
                 Qt.Key_Exclam, Qt.Key_QuoteLeft, Qt.Key_QuoteDbl,
                 Qt.Key_Aring]

        row_4 = [Qt.Key_Aring, Qt.Key_Space, Qt.Key_Aring, Qt.Key_Aring]

        self.keyboard_symbols_keys = [row_1, row_2, row_3, row_4]
项目:headcache    作者:s9w    | 项目源码 | 文件源码
def keyPressEvent(self, ev):
        super().keyPressEvent(ev)

        # arrow keys are delegated to the result list
        if ev.key() in [Qt.Key_Up, Qt.Key_Down]:
            self.parent().parent().overlay.l1.keyPressEvent(ev)
            return

        elif ev.key() == Qt.Key_Return:
            self.parent().parent().goto_result()
            return

        # only search when query is long enough and different from last (not
        # just cursor changes)
        length_threshold = 2
        length_criteria = len(self.text()) >= length_threshold
        if self.text() != self.query_old and length_criteria:
            self.parent().parent().search_with(self.text())
        self.parent().parent().overlay.update_visibility(length_criteria)

        self.query_old = self.text()
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def __init__(self):
        self.version = 100  # Assume oldest config
        self.root_dir = QDir().currentPath()
        self.send_sleep = 0.1
        self.read_sleep = 0.1
        self.use_transfer_scripts = True
        self.external_transfer_scripts_folder = None
        self.wifi_presets = []
        self.python_flash_executable = None
        self.last_firmware_directory = None
        self.debug_mode = False
        self._geometries = {}
        self.external_editor_path = None
        self.external_editor_args = None
        self.new_line_key = QKeySequence(Qt.SHIFT + Qt.Key_Return, Qt.SHIFT + Qt.Key_Enter)
        self.send_key = QKeySequence(Qt.Key_Return, Qt.Key_Enter)
        self.terminal_tab_spaces = 4
        self.mpy_cross_path = None
        self.preferred_port = None
        self.auto_transfer = False

        if not self.load():
            if not self.load_old():
                # No config found, init at newest version
                self.version = Settings.newest_version
                return

        self._update_config()
项目:QtPropertyBrowserV2.6-for-pyqt5    作者:theall    | 项目源码 | 文件源码
def eventFilter(self, obj, ev):
        if (obj == self.m_button):
            k = ev.type()
            if k in [QEvent.KeyPress, QEvent.KeyRelease]:# Prevent the QToolButton from handling Enter/Escape meant control the delegate
                x = ev.key()
                if x in [Qt.Key_Escape, Qt.Key_Enter, Qt.Key_Return]:
                    ev.ignore()
                    return True

        return super(QtFontEditWidget, self).eventFilter(obj, ev)
项目:tvlinker    作者:ozmartian    | 项目源码 | 文件源码
def keyPressEvent(self, event: QKeyEvent) -> None:
        if event.key() in (Qt.Key_Enter, Qt.Key_Return):
            return
        super(Settings, self).keyPressEvent(event)
项目:AlphaHooks    作者:AlphaHooks    | 项目源码 | 文件源码
def eventFilter(self, source, event):

        # Console Input
        if source is self.ui.console_input:
            if event.type() == QEvent.KeyPress:
                if event.key() in (Qt.Key_Enter, Qt.Key_Return):
                    command = self.ui.console_input.text()
                    if command != "":
                        readline.add_history(
                            command
                        )
                    self.length = readline.get_current_history_length()
                    self.index = -1

                if event.key() == Qt.Key_Up:
                    if self.index < self.length:
                        self.index += 1
                        command = readline.get_history_item(
                            self.length - self.index
                        )
                        self.ui.console_input.setText(
                            command
                        )

                if event.key() == Qt.Key_Down:
                    if self.index > 0:
                        self.index -= 1
                        command = readline.get_history_item(
                            self.length - self.index
                        )

                        self.ui.console_input.setText(
                            command
                        )

            return False
        return False
项目:mpvQC    作者:Frechdachs    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
            commentlistview.delegate.commitData.emit(self)
            commentlistview.delegate.closeEditor.emit(self)
            event.accept()
        else:
            super(CommentTextEdit, self).keyPressEvent(event)
项目:COMTool    作者:Neutree    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Control:
            self.keyControlPressed = True
        elif event.key() == Qt.Key_Return or event.key()==Qt.Key_Enter:
            if self.keyControlPressed:
                self.sendData()
        elif event.key() == Qt.Key_L:
            if self.keyControlPressed:
                self.sendArea.clear()
        elif event.key() == Qt.Key_K:
            if self.keyControlPressed:
                self.receiveArea.clear()
        return
项目:chronophore    作者:mesbahamin    | 项目源码 | 文件源码
def keyPressEvent(self, e):
        if e.key() == Qt.Key_Escape:
            self.close()
        if e.key() == Qt.Key_Return or e.key() == Qt.Key_Enter:
            self._sign_button_press()
项目:Cite    作者:siudej    | 项目源码 | 文件源码
def eventFilter(self, source, event):
        """ Add/remove a few keyboard and mouse events. """
        if source is self.searchQuery:
            if event.type() == QEvent.KeyPress:
                if event.key() == Qt.Key_Return:
                    if event.modifiers() == Qt.ShiftModifier:
                        self.on_arxiv_clicked()
                        return True
                    elif event.modifiers() == Qt.ControlModifier:
                        self.on_msn_clicked()
                        return True
                    elif event.modifiers() == Qt.AltModifier:
                        self.on_zbl_clicked()
                        return True
        return QMainWindow.eventFilter(self, source, event)
项目:pyqt5    作者:yurisnm    | 项目源码 | 文件源码
def set_up_keyboard_keys(self):

        row_1 = [Qt.Key_Q, Qt.Key_W, Qt.Key_E, Qt.Key_R, Qt.Key_T, Qt.Key_Y,
                 Qt.Key_Y, Qt.Key_I, Qt.Key_O, Qt.Key_P, Qt.Key_Backspace]
        row_2 = [Qt.Key_A, Qt.Key_S, Qt.Key_D, Qt.Key_F, Qt.Key_G, Qt.Key_H,
                 Qt.Key_J, Qt.Key_K, Qt.Key_L, Qt.Key_Ccedilla, Qt.Key_Return]
        row_3 = [Qt.Key_Aring, Qt.Key_Z, Qt.Key_X, Qt.Key_C, Qt.Key_V,
                 Qt.Key_B, Qt.Key_N, Qt.Key_M, Qt.Key_Comma, Qt.Key_Period,
                 Qt.Key_Question, Qt.Key_Aring]
        row_4 = [Qt.Key_Aring, Qt.Key_Space,
                 Qt.Key_Left, Qt.Key_Right, Qt.Key_Aring]
        self.keyboard_keys = [row_1, row_2, row_3, row_4]
项目:pyqt5    作者:yurisnm    | 项目源码 | 文件源码
def set_up_keyboard_numbers_keys(self):
        row_1 = [Qt.Key_1, Qt.Key_2, Qt.Key_3, Qt.Key_4, Qt.Key_5, Qt.Key_6,
                 Qt.Key_7, Qt.Key_8, Qt.Key_9, Qt.Key_0, Qt.Key_Backspace]

        row_2 = [Qt.Key_Minus, Qt.Key_Slash, Qt.Key_Colon, Qt.Key_Semicolon,
                 Qt.Key_ParenLeft, Qt.Key_ParenRight, Qt.Key_Dollar,
                 Qt.Key_Ampersand, Qt.Key_At, Qt.Key_Return]

        row_3 = [Qt.Key_Aring, Qt.Key_Period, Qt.Key_Comma, Qt.Key_Question,
                 Qt.Key_Exclam, Qt.Key_QuoteLeft, Qt.Key_QuoteDbl,
                 Qt.Key_Aring]

        row_4 = [Qt.Key_Aring, Qt.Key_Space, Qt.Key_Aring, Qt.Key_Aring]

        self.keyboard_numbers_keys = [row_1, row_2, row_3, row_4]
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        key = event.key()
        if key == Qt.Key_Return:
            cursor = self.textCursor()
            indentLvl = self.findLineIndentLevel()
            if self.openBlockDelimiter is not None:
                cursor.movePosition(QTextCursor.PreviousCharacter,
                                    QTextCursor.KeepAnchor)
                if cursor.selectedText() == self.openBlockDelimiter:
                    indentLvl += 1
            super(BaseCodeEditor, self).keyPressEvent(event)
            newLineSpace = "".join(self._indent for _ in range(indentLvl))
            cursor = self.textCursor()
            cursor.insertText(newLineSpace)
        elif key in (Qt.Key_Backspace, Qt.Key_Backtab):
            cursor = self.textCursor()
            if key == Qt.Key_Backtab and cursor.hasSelection():
                self.performLinewiseIndent(cursor, False)
            else:
                cursor.movePosition(QTextCursor.PreviousCharacter,
                                    QTextCursor.KeepAnchor,
                                    len(self._indent))
                if cursor.selectedText() == self._indent:
                    cursor.removeSelectedText()
                else:
                    super(BaseCodeEditor, self).keyPressEvent(event)
        elif key == Qt.Key_Tab:
            cursor = self.textCursor()
            if cursor.hasSelection():
                self.performLinewiseIndent(cursor)
            else:
                cursor.insertText(self._indent)
        else:
            super(BaseCodeEditor, self).keyPressEvent(event)

    # --------------
    # Other builtins
    # --------------
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        key = event.key()
        if key == Qt.Key_Return:
            index = self._selected
            if index is not None:
                glyph = self._glyphRecords[index].glyph
                self.glyphActivated.emit(glyph)
        else:
            super(GlyphLineWidget, self).keyPressEvent(event)
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        key = event.key()
        modifiers = event.modifiers()
        if key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right):
            self._arrowKeyPressEvent(event)
        elif key == Qt.Key_Return:
            index = self._lastSelectedCell
            if index is not None:
                self.glyphActivated.emit(self._glyphs[index])
        elif modifiers in (Qt.NoModifier, Qt.ShiftModifier):
            self._glyphNameInputEvent(event)
        else:
            super(GlyphCellWidget, self).keyPressEvent(event)
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() & Qt.Key_Return:
            if self._mayClearColor and event.modifiers() & Qt.AltModifier:
                self.setColor(None)
            else:
                self.pickColor()
        else:
            super(ColorVignette, self).keyPressEvent(event)
项目:udpsocket-gobang    作者:gzdaijie    | 项目源码 | 文件源码
def keyPressEvent(self,event):
        key = event.key()
        if key == Qt.Key_Enter or key == Qt.Key_Return:
            self.chat()
项目:uitester    作者:IfengAutomation    | 项目源码 | 文件源码
def keyPressEvent(self, e):
        completion_prefix = self.text_under_cursor()
        if self.cmp and self.popup_widget.func_list_widget.isVisible():
            current_row = self.popup_widget.func_list_widget.currentRow()
            if e.key() == Qt.Key_Down:
                self.current_item_down(current_row)
                return

            if e.key() == Qt.Key_Up:
                self.current_item_up(current_row)
                return

            if e.key() in (Qt.Key_Return, Qt.Key_Enter):
                selected_word = self.popup_widget.func_list_widget.currentItem().text()
                self.insert_func_name_signal.emit(completion_prefix, selected_word)
                return

        if e.key() in (Qt.Key_Return, Qt.Key_Enter):
            self.parse_content()

        is_shortcut = ((e.modifiers() & Qt.ControlModifier) and e.key() == Qt.Key_E)  # shortcut key:ctrl + e
        if is_shortcut:
            self.cmp.update("", self.popup_widget)
            self.update_popup_widget_position()
            self.activateWindow()
            return

        if not self.cmp or not is_shortcut:
            super(TextEdit, self).keyPressEvent(e)
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def keyPressEvent(self, QKeyEvent):
        if QKeyEvent.key() == Qt.Key_Escape:
            pass

        if QKeyEvent.key() == Qt.Key_Enter or QKeyEvent.key() == Qt.Key_Return:
            self.slot_login()
项目:Pesterchum-Discord    作者:henry232323    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        '''Use enter key to send'''
        if event.key() == Qt.Key_Return:
            self.send()
项目:Pesterchum-Discord    作者:henry232323    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        '''Use enter key to send'''
        if event.key() == Qt.Key_Return:
            self.send()
项目:Pesterchum-Discord    作者:henry232323    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return:
            self.send()
项目:opcua-widgets    作者:FreeOpcUa    | 项目源码 | 文件源码
def modify_item(self, text, val, match_to_use=0):
        """
        modify the current item and set its displayed value to 'val'
        """
        idxlist = self.widget.model.match(self.widget.model.index(0, 0), Qt.DisplayRole, text, match_to_use + 1, Qt.MatchExactly | Qt.MatchRecursive)
        if not idxlist:
            raise RuntimeError("Item with text '{}' not found".format(text))
        idx = idxlist[match_to_use]
        self.widget.view.setCurrentIndex(idx)
        idx = idx.sibling(idx.row(), 1)
        self.widget.view.edit(idx)
        editor = self.widget.view.focusWidget()
        if not editor:
            print(app.focusWidget())
            print("NO EDITOR WIDGET")
            #QTest.keyClick(self.widget.view, Qt.Key_Return)
            from IPython import embed 
            embed()
            raise RuntimeError("Could not get editor widget!, it does not have the focus")

        if hasattr(editor, "_current_node"):
            editor._current_node = val
        elif hasattr(editor, "setCurrentText"):
            editor.setCurrentText(val)
        else:
            editor.setText(val)
        self.widget.view.commitData(editor)
        self.widget.view.closeEditor(editor, QAbstractItemDelegate.NoHint)
        self.widget.view.reset()
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def keyPressEvent(self, event: QKeyEvent):
        if event.key() in (Qt.Key_Enter, Qt.Key_Return):
            selected = [index.row() for index in self.selectedIndexes()]
            if len(selected) > 0:
                self.edit_on_item_triggered.emit(min(selected))
        else:
            super().keyPressEvent(event)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def keyPressEvent(self, event: QKeyEvent):
        if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
            return
        else:
            super().keyPressEvent(event)
项目:RRPam-WDS    作者:asselapathirana    | 项目源码 | 文件源码
def set_text_textbox(item, value="", enter=False):
    item.clear()
    QTest.keyClicks(item, str(value))
    if (enter):
        QTest.keyPress(item, Qt.Key_Return)
项目:RRPam-WDS    作者:asselapathirana    | 项目源码 | 文件源码
def set_text_spinbox(item, value=""):  # useful for qtests.

    for i in range(3):
        QTest.keyPress(item, Qt.Key_Backspace)
        QTest.keyPress(item, Qt.Key_Delete)
    QTest.keyClicks(item, str(value))
    QTest.keyPress(item, Qt.Key_Return)
项目:RRPam-WDS    作者:asselapathirana    | 项目源码 | 文件源码
def test_get_information_returns_the_right_data(self):
        # create some groups
        item = self.aw.datawindow.ui.no_groups
        set_text_spinbox(item, 12)
        A1 = 1.12e-4
        N01 = 1.34e-5
        cost1 = 22.
        A2 = 1.2e-4
        N02 = 2.2e-1
        one = self.aw.datawindow.assetgrouplist[11]
        set_text_textbox(one.A, A1)
        A1 = float(one.A.text())
        set_text_textbox(one.N0, N01)
        N01 = float(one.N0.text())
        set_text_textbox(one.cost, cost1)
        cost1 = float(one.cost.text())
        box = self.aw.datawindow.assetgrouplist[2]
        set_text_textbox(box.A, A2)
        A2 = float(box.A.text())
        set_text_textbox(box.N0, N02)
        N02 = float(box.N0.text())
        set_text_spinbox(item, 4)
        QTest.keyPress(item, Qt.Key_Return)  # now we have only 4 active items
        active, values = self.aw.datawindow.get_information(all=True)
        self.assertEqual(active, 4)
        self.assertEqual(values[11][0], A1)
        self.assertEqual(values[11][1], N01)
        self.assertEqual(values[11][2], cost1)
        self.assertEqual(values[2][0], A2)
        self.assertEqual(values[2][1], N02)
项目:RRPam-WDS    作者:asselapathirana    | 项目源码 | 文件源码
def test_number_of_property_groups_is_kept_equal_to_no_groups_spinbox(self):
        self.compare()
        item = self.aw.datawindow.ui.no_groups
        set_text_spinbox(item, "12")
        self.compare()
        set_text_spinbox(item, "2")
        self.compare()
        set_text_spinbox(item, "8")
        QTest.keyPress(item, Qt.Key_Return)
        self.compare()
        set_text_spinbox(item, "-5")
        self.compare()
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        key = event.key()
        if key == Qt.Key_Return:
            cursor = self.textCursor()
            indentLvl = self.findLineIndentLevel()
            newBlock = False

            pos = cursor.position()
            cursor.movePosition(QTextCursor.PreviousCharacter,
                                QTextCursor.KeepAnchor)
            if cursor.selectedText() == self.openBlockDelimiter:
                # We don't add a closing tag if there is text right
                # below with the same indentation level because in
                # that case the user might just be looking to add a
                # new line
                ok = cursor.movePosition(QTextCursor.Down)
                if ok:
                    downIndentLvl = self.findLineIndentLevel(cursor)
                    cursor.select(QTextCursor.LineUnderCursor)
                    if (cursor.selectedText().strip(
                            ) == '' or downIndentLvl <= indentLvl):
                        newBlock = True
                    cursor.movePosition(QTextCursor.Up)
                else:
                    newBlock = True
                indentLvl += 1

            if newBlock:
                cursor.select(QTextCursor.LineUnderCursor)
                txt = cursor.selectedText().lstrip(" ").split(" ")
                if len(txt) > 1:
                    if len(txt) < 3 and txt[-1][-1] == self.openBlockDelimiter:
                        feature = txt[-1][:-1]
                    else:
                        feature = txt[1]
                else:
                    feature = None
            cursor.setPosition(pos)

            cursor.beginEditBlock()
            cursor.insertText("\n")
            newLineSpace = "".join(self._indent for _ in range(indentLvl))
            cursor.insertText(newLineSpace)
            if newBlock:
                cursor.insertText("\n")
                newLineSpace = "".join((newLineSpace[:-len(self._indent)],
                                        "} ", feature, ";"))
                cursor.insertText(newLineSpace)
                cursor.movePosition(QTextCursor.Up)
                cursor.movePosition(QTextCursor.EndOfLine)
                self.setTextCursor(cursor)
            cursor.endEditBlock()
        else:
            super(FeatureCodeEditor, self).keyPressEvent(event)