Python PyQt5.QtCore.Qt.Key_Return() Examples

The following are 25 code examples of PyQt5.QtCore.Qt.Key_Return(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: keyutils.py    From qutebrowser with GNU General Public License v3.0 9 votes vote down vote up
def text(self) -> str:
        """Get the text which would be displayed when pressing this key."""
        control = {
            Qt.Key_Space: ' ',
            Qt.Key_Tab: '\t',
            Qt.Key_Backspace: '\b',
            Qt.Key_Return: '\r',
            Qt.Key_Enter: '\r',
            Qt.Key_Escape: '\x1b',
        }

        if self.key in control:
            return control[self.key]
        elif not _is_printable(self.key):
            return ''

        text = QKeySequence(self.key).toString()
        if not self.modifiers & Qt.ShiftModifier:  # type: ignore[operator]
            text = text.lower()
        return text 
Example #2
Source File: command.py    From qutebrowser with GNU General Public License v3.0 7 votes vote down vote up
def keyPressEvent(self, e: QKeyEvent) -> None:
        """Override keyPressEvent to ignore Return key presses.

        If this widget is focused, we are in passthrough key mode, and
        Enter/Shift+Enter/etc. will cause QLineEdit to think it's finished
        without command_accept to be called.
        """
        text = self.text()
        if text in modeparsers.STARTCHARS and e.key() == Qt.Key_Backspace:
            e.accept()
            modeman.leave(self._win_id, usertypes.KeyMode.command,
                          'prefix deleted')
            return
        if e.key() == Qt.Key_Return:
            e.ignore()
            return
        else:
            super().keyPressEvent(e) 
Example #3
Source File: ModulatorDialog.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def keyPressEvent(self, event: QKeyEvent):
        if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
            return
        else:
            super().keyPressEvent(event) 
Example #4
Source File: 猜数游戏.py    From Python-Application with GNU General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, e):
        # 设置快捷键
        if e.key() == Qt.Key_Return:
            self.guess()
        elif e.key() == Qt.Key_Escape:
            qApp.quit()
        elif e.key() == Qt.Key_R:
            self.reset() 
Example #5
Source File: weather.py    From Python-Application with GNU General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, e):
        # 设置快捷键
        if e.key() == Qt.Key_Return:
                self.queryWeather() 
Example #6
Source File: GeneratorListView.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #7
Source File: watchpoints.py    From Dwarf with GNU General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        """ Override keyPressEvent to allow close with Enter
        """
        if event.key() == Qt.Key_Return:
            return self.accept()

        return super().keyPressEvent(event) 
Example #8
Source File: list_pick.py    From Dwarf with GNU General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return:
            self._callback()
        else:
            super(PickList, self).keyPressEvent(event) 
Example #9
Source File: code_editor.py    From Dwarf with GNU General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        tc = self.textCursor()

        if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return or event.key() == Qt.Key_Tab:
            if self.completer and self.completer.popup().isVisible():
                self.completer.insertText.emit(self.completer.getSelected())
                self.completer.setCompletionMode(QCompleter.PopupCompletion)
                event.ignore()
                return

        super().keyPressEvent(event)

        tc.select(QTextCursor.WordUnderCursor)
        cr = self.cursorRect()

        if self.completer:
            if tc.selectedText():
                self.completer.setCompletionPrefix(tc.selectedText())
                popup = self.completer.popup()
                #popup.setCurrentIndex(self.completer.completionModel().index(0, 0))

                cr.setWidth(
                    self.completer.popup().sizeHintForColumn(0) +
                    self.completer.popup().verticalScrollBar().sizeHint().width())
                self.completer.complete(cr)
            else:
                self.completer.popup().hide() 
Example #10
Source File: widget_console.py    From Dwarf with GNU General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        # when codecompletion popup dont respond to enter
        if self.completer and self.completer.popup() and self.completer.popup(
        ).isVisible():
            event.ignore()
            return super().keyPressEvent(event)

        if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
            cmd = self.toPlainText()
            l = len(self.cmds)
            if l > 0:
                if l > 100:
                    self.cmds.pop(0)
                if cmd != self.cmds[l - 1]:
                    self.cmds.append(cmd)
            else:
                self.cmds.append(cmd)
            self.cmd_index = 0
            self.onEnterKeyPressed.emit(cmd)
            self.setPlainText('')
        elif event.key() == Qt.Key_Up:
            l = len(self.cmds)
            try:
                self.setPlainText(self.cmds[l - 1 - self.cmd_index])
                if self.cmd_index < l - 1:
                    self.cmd_index += 1
            except:
                pass
        elif event.key() == Qt.Key_Down:
            try:
                if self.cmd_index >= 0:
                    self.cmd_index -= 1
                self.setPlainText(
                    self.cmds[len(self.cmds) - 1 - self.cmd_index])
            except:
                self.setPlainText('')
                self.cmd_index = 0
        else:
            return super().keyPressEvent(event) 
Example #11
Source File: dialog_list.py    From Dwarf with GNU General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        super(ListDialog, self).keyPressEvent(event)
        if event.key() == Qt.Key_Return:
            self.accept() 
Example #12
Source File: mainwin.py    From QssStylesheetEditor with GNU General Public License v3.0 5 votes vote down vote up
def textChanged(self, e):  # QKeyEvent(QEvent.KeyPress, Qt.Key_Enter, Qt.NoModifier)
        # if (32<e.key()<96 or 123<e.key()<126 or 0x1000001<e.key()<0x1000005 or e.key==Qt.Key_Delete):
        # 大键盘为Ret小键盘为Enter
        if (e.key() in (Qt.Key_Return, Qt.Key_Enter, Qt.Key_Semicolon, Qt.Key_BraceRight, Qt.Key_Up, Qt.Key_Down,
                        Qt.Key_Left, Qt.Key_Right, Qt.Key_Tab, Qt.Key_Delete, Qt.Key_Backspace)):
            self.renderStyle()
            self.loadColorPanel()

        self.actions["undo"].setEnabled(self.editor.isUndoAvailable())
        self.actions["redo"].setEnabled(self.editor.isRedoAvailable()) 
Example #13
Source File: textclient.py    From bluesky with GNU General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        ''' Handle Enter keypress to send a command to BlueSky. '''
        if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
            if bsclient is not None:
                bsclient.stack(self.toPlainText())
                echobox.echo(self.toPlainText())
            self.setText('')
        else:
            super().keyPressEvent(event) 
Example #14
Source File: TextEditor.py    From Hydra with GNU General Public License v3.0 5 votes vote down vote up
def keyReleaseEvent(self, e):
        if e.key() == Qt.Key_Return:
            try:
                self.updateAutoComplete(self.parent.fileName)
            except AttributeError as E:
                print(E, "on line 210 in TextEditor.py")

        if e.key() == Qt.Key_Backspace:
            pass 
Example #15
Source File: login_widget.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return:
            self.try_login()
        event.accept() 
Example #16
Source File: custom_dialogs.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return:
            self._on_button_clicked()
        event.accept() 
Example #17
Source File: claim_device_widget.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return and not self.claim_device_job:
            self.claim_clicked()
        event.accept() 
Example #18
Source File: claim_user_widget.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Return and not self.claim_user_job:
            self.claim_clicked()
        event.accept() 
Example #19
Source File: Main.py    From COMTool with GNU Lesser General Public License v3.0 5 votes vote down vote up
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() 
Example #20
Source File: QtKeyDevice.py    From Uranium with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _qtKeyToUMKey(self, key):
        if key == Qt.Key_Shift:
            return KeyEvent.ShiftKey
        elif key == Qt.Key_Control:
            return KeyEvent.ControlKey
        elif key == Qt.Key_Alt:
            return KeyEvent.AltKey
        elif key == Qt.Key_Space:
            return KeyEvent.SpaceKey
        elif key == Qt.Key_Meta:
            return KeyEvent.MetaKey
        elif key == Qt.Key_Enter or key == Qt.Key_Return:
            return KeyEvent.EnterKey
        elif key == Qt.Key_Up:
            return KeyEvent.UpKey
        elif key == Qt.Key_Down:
            return KeyEvent.DownKey
        elif key == Qt.Key_Left:
            return KeyEvent.LeftKey
        elif key == Qt.Key_Right:
            return KeyEvent.RightKey
        elif key == Qt.Key_Minus:
            return KeyEvent.MinusKey
        elif key == Qt.Key_Underscore:
            return KeyEvent.UnderscoreKey
        elif key == Qt.Key_Plus:
            return KeyEvent.PlusKey
        elif key == Qt.Key_Equal:
            return KeyEvent.EqualKey

        return key 
Example #21
Source File: filter_widget.py    From execution-trace-viewer with MIT License 5 votes vote down vote up
def on_filter_combo_box_key_pressed(self, event):
        """Checks if enter is pressed on filterEdit"""
        key = event.key()
        if key in (Qt.Key_Return, Qt.Key_Enter):
            self.on_filter_btn_clicked()
        QComboBox.keyPressEvent(self.filter_combo_box, event) 
Example #22
Source File: settings.py    From uPyLoader with MIT License 5 votes vote down vote up
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.use_custom_transfer_scripts = False
        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() 
Example #23
Source File: console.py    From bluesky with GNU General Public License v3.0 4 votes vote down vote up
def keyPressEvent(self, event):
        ''' Handle keyboard input for bluesky. '''
        # Enter-key: enter command
        if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
            if self.command_line:
                # emit a signal with the command for the simulation thread
                self.stack(self.command_line)
                # Clear any shape command preview on the radar display
                # self.radarwidget.previewpoly(None)
                return

        newcmd = self.command_line
        cursorpos = None
        if event.key() >= Qt.Key_Space and event.key() <= Qt.Key_AsciiTilde:
            pos = self.lineEdit.cursor_pos()
            newcmd = newcmd[:pos] + event.text() + newcmd[pos:]
            # Update the cursor position with the length of the added text
            cursorpos = pos + len(event.text())
        elif event.key() == Qt.Key_Backspace:
            pos = self.lineEdit.cursor_pos()
            newcmd = newcmd[:pos - 1] + newcmd[pos:]
            cursorpos = pos - 1
        elif event.key() == Qt.Key_Tab:
            if newcmd:
                newcmd, displaytext = autocomplete.complete(newcmd)
                if displaytext:
                    self.echo(displaytext)
        elif not event.modifiers() & (Qt.ControlModifier | Qt.ShiftModifier | 
                                        Qt.AltModifier | Qt.MetaModifier):
            if event.key() == Qt.Key_Up:
                if self.history_pos == 0:
                    self.command_mem = newcmd
                if len(self.command_history) >= self.history_pos + 1:
                    self.history_pos += 1
                    newcmd = self.command_history[-self.history_pos]

            elif event.key() == Qt.Key_Down:
                if self.history_pos > 0:
                    self.history_pos -= 1
                    if self.history_pos == 0:
                        newcmd = self.command_mem
                    else:
                        newcmd = self.command_history[-self.history_pos]

            elif event.key() == Qt.Key_Left:
                self.lineEdit.cursor_left()

            elif event.key() == Qt.Key_Right:
                self.lineEdit.cursor_right()
            else:
                # Remaining keys are things like sole modifier keys, and function keys
                super(Console, self).keyPressEvent(event)
        else:
            event.ignore()
            return

        # Final processing of the command line
        self.set_cmdline(newcmd, cursorpos) 
Example #24
Source File: Content.py    From Hydra with GNU General Public License v3.0 4 votes vote down vote up
def keyPressEvent(self, event):

        if (
            self.completer
            and self.completer.popup()
            and self.completer.popup().isVisible()
        ):
            if event.key() in (
                Qt.Key_Enter,
                Qt.Key_Return,
                Qt.Key_Escape,
                Qt.Key_Tab,
                Qt.Key_Backtab,
            ):
                event.ignore()
                return

        isShortcut = event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_B

        if not self.completer or not isShortcut:
            QPlainTextEdit.keyPressEvent(self.editor, event)

        completionPrefix = self.textUnderCursor()

        if not isShortcut:
            if self.completer.popup():
                self.completer.popup().hide()
            return

        self.completer.setCompletionPrefix(completionPrefix)

        popup = self.completer.popup()

        popup.setFont(self.font)
        popup.setCurrentIndex(self.completer.completionModel().index(0, 0))

        cr = self.editor.cursorRect()
        cr.translate(QPoint(10, 10))
        cr.setWidth(
            self.completer.popup().sizeHintForColumn(0)
            + self.completer.popup().verticalScrollBar().sizeHint().width()
        )
        self.completer.complete(cr) 
Example #25
Source File: forward_keyboard.py    From MaixPy_scripts with MIT License 4 votes vote down vote up
def keyPressEvent(self, event):
        print(event.key())
        if event.key() == Qt.Key_M:
            self.send_flag = False
            self.com.write(b"m")
            self.send_flag = False
        elif event.key() == Qt.Key_Return or event.key()==Qt.Key_Enter:
            self.send_flag = False
            self.com.write(b"m")
            self.send_flag = False
        elif event.key() == Qt.Key_N or event.key() == 92:
            self.send_flag = False
            self.com.write(b"n")
            self.send_flag = False
        elif event.key() == Qt.Key_Minus:
            self.send_flag = False
            self.com.write(b"-")
            self.send_flag = False
        elif event.key() == Qt.Key_Equal:
            self.send_flag = False
            self.com.write(b"=")
            self.send_flag = False
        elif event.key() == Qt.Key_W or event.key() == Qt.Key_Up:
            self.send_flag = True
            self.key.append(b"w")
        elif event.key() == Qt.Key_A or event.key() == Qt.Key_Left:
            self.send_flag = True
            self.key.append(b"a")
        elif event.key() == Qt.Key_S or event.key() == Qt.Key_Down:
            self.send_flag = True
            self.key.append(b"s")
        elif event.key() == Qt.Key_D or event.key() == Qt.Key_Right:
            self.send_flag = True
            self.key.append(b"d")
        elif event.key() == Qt.Key_J:
            self.send_flag = True
            self.key.append(b"j")
        elif event.key() == Qt.Key_K:
            self.send_flag = True
            self.key.append(b"k")
        elif event.key() == Qt.Key_Escape:
            self.send_flag = False
            self.com.write(b"\x03")
        elif event.key() == Qt.Key_Control:
            self.keyControlPressed = True
        elif event.key() == Qt.Key_C:
            if self.keyControlPressed:
                self.send_flag = False
                self.com.write(b"\x03")
        # self.key_label.setText(self.key.decode())