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

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

项目: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)
项目:tahoe-gui    作者:LeastAuthority    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        key = event.key()
        text = self.text()
        if key == Qt.Key_Space:
            if text and not text.endswith('-'):
                self.setText(text + '-')
        elif key == Qt.Key_Tab:
            if text and len(text.split('-')) < 3 and not text.endswith('-'):
                self.setText(text + '-')
            else:
                self.setText(text)
        elif key == Qt.Key_Escape:
            if text:
                self.parent.reset()
            else:
                self.parent.close()
        else:
            return QLineEdit.keyPressEvent(self, event)
项目:gui_tool    作者:UAVCAN    | 项目源码 | 文件源码
def keyPressEvent(self, qkeyevent):
        super(SearchBar, self).keyPressEvent(qkeyevent)
        if qkeyevent.key() == Qt.Key_Escape:
            self.setVisible(False)
            self.show_search_bar_button.setChecked(False)
项目:gui_tool    作者:UAVCAN    | 项目源码 | 文件源码
def keyPressEvent(self, qkeyevent):
            super(FilterBar.Filter, self).keyPressEvent(qkeyevent)
            if qkeyevent.key() == Qt.Key_Escape:
                self.on_remove(self)
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape and self._flashing:
            event.ignore()
项目: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)
项目:EMFT    作者:132nd-etcher    | 项目源码 | 文件源码
def __init__(self):
        # Fucking QMainWindow calls a general super().__init__ on every parent class, don't call them here !
        flags = Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint
        flags = flags | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint

        self.helpers = {}

        QMainWindow.__init__(
            self,
            flags=flags
        )

        self.resize(1024, 768)

        self.tabs = TabWidget()

        layout = VLayout(
            [
                self.tabs
            ]
        )

        layout.setContentsMargins(10, 10, 10, 10)

        window = Widget()
        window.setLayout(layout)

        self.setCentralWidget(window)

        self.setWindowIcon(QIcon(constant.DEFAULT_ICON))

        self.exit_shortcut = Shortcut(QKeySequence(Qt.Key_Escape), self, self.exit)

        self.setWindowTitle(
            '{} v{} - {}'.format(constant.APP_SHORT_NAME,
                                 __version__,
                                 constant.APP_RELEASE_NAME))
项目:pyopenvr    作者:cmbruns    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        "press ESCAPE to quit the application"
        key = event.key()
        if key == Qt.Key_Escape:
            self.app.quit()
项目:vidcutter    作者:ozmartian    | 项目源码 | 文件源码
def keyPressEvent(self, event: QKeyEvent) -> None:
        if event.key() in {Qt.Key_F, Qt.Key_Escape}:
            event.accept()
            if self.isFullScreen():
                self._exitFullScreen()
            self.parent.toggleFullscreen()
        elif self.isFullScreen():
            self.parent.keyPressEvent(event)
        else:
            super(mpvWidget, self).keyPressEvent(event)
项目: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()
项目:DicomBrowser    作者:ericspod    | 项目源码 | 文件源码
def keyPressEvent(self,e):
        '''Close the window if escape is pressed, otherwise do as inherited.'''
        if e.key() == Qt.Key_Escape:
            self.close()
        else:
            QtGui.QMainWindow.keyPressEvent(self,e)
项目:SiebenApp    作者:ahitrin    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        key_handlers = {
            Qt.Key_1: self.select_number(1),
            Qt.Key_2: self.select_number(2),
            Qt.Key_3: self.select_number(3),
            Qt.Key_4: self.select_number(4),
            Qt.Key_5: self.select_number(5),
            Qt.Key_6: self.select_number(6),
            Qt.Key_7: self.select_number(7),
            Qt.Key_8: self.select_number(8),
            Qt.Key_9: self.select_number(9),
            Qt.Key_0: self.select_number(0),
            Qt.Key_A: self.start_edit(self.goals.add, 'Add new goal'),
            Qt.Key_C: self.with_refresh(self.goals.toggle_close),
            Qt.Key_D: self.with_refresh(self.goals.delete),
            Qt.Key_I: self.start_edit(self.goals.insert, 'Insert new goal'),
            Qt.Key_L: self.with_refresh(self.goals.toggle_link),
            Qt.Key_Q: self.quit_app.emit,
            Qt.Key_R: self.start_edit(self.goals.rename, 'Rename goal'),
            Qt.Key_S: self.with_refresh(self.goals.swap_goals),
            Qt.Key_V: self.toggle_view,
            Qt.Key_Z: self.toggle_zoom,
            Qt.Key_Escape: self.cancel_edit,
            Qt.Key_Space: self.with_refresh(self.goals.hold_select),
        }
        if event.key() in key_handlers:
            key_handlers[event.key()]()
        else:
            super().keyPressEvent(event)
项目:pisi-player    作者:mthnzbk    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape and self.isFullScreen():
            self.showNormal()

        if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_Q:
            self.close()
            sys.exit()

        if event.key() == Qt.Key_Space:
            if self.player.player.state() == self.player.player.PlayingState:
                self.player.pause()
            elif self.player.player.state() == self.player.player.StoppedState or self.player.player.PausedState:
                self.player.play()

        if event.key() == Qt.Key_Plus:
            self.player.setVolume(self.player.volume() + 5)

        if event.key() == Qt.Key_Minus:
            self.player.setVolume(self.player.volume() - 5)

        if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_M:
            self.player.setMuted(not self.player.isMuted())

        if event.key() == Qt.Key_Right:
            self.player.player.setPosition(self.player.player.position() + 10000)

        if event.key() == Qt.Key_Left:
            self.player.player.setPosition(self.player.player.position() - 10000)

        if event.key() == Qt.Key_Up:
            self.player.player.setPosition(self.player.player.position() + 60000)

        if event.key() == Qt.Key_Down:
            self.player.player.setPosition(self.player.player.position() - 60000)

        super().keyPressEvent(event)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            QApplication.quit()
        elif event.key() == Qt.Key_F1:
            s = ""
            s += "\nAdapt: "
            s += ["on", "off"][Colors.noAdapt]
            s += "\nAdaption occured: "
            s += ["no", "yes"][Colors.adapted]
            w = QWidget()
            s += "\nColor bit depth: %d" % w.depth()
            s += "\nWanted FPS: %d" % Colors.fps
            s += "\nBenchmarked FPS: ";
            if Colors.benchmarkFps != -1:
                s += "%d" % Colors.benchmarkFps
            else:
                s += "not calculated"
            s += "\nAnimations: ";
            s += ["on", "off"][Colors.noAnimations]
            s += "\nBlending: ";
            s += ["on", "off"][Colors.useEightBitPalette]
            s += "\nTicker: ";
            s += ["on", "off"][Colors.noTicker]
            s += "\nPixmaps: ";
            s += ["off", "on"][Colors.usePixmaps]
            s += "\nRescale images on resize: ";
            s += ["on", "off"][Colors.noRescale]
            s += "\nTimer based updates: ";
            s += ["on", "off"][Colors.noTimerUpdate]
            s += "\nSeparate loop: ";
            s += ["no", "yes"][Colors.useLoop]
            s += "\nScreen sync: ";
            s += ["yes", "no"][Colors.noScreenSync]
            QMessageBox.information(None, "Current configuration", s)

        super(MainWindow, self).keyPressEvent(event)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            QApplication.quit()
        elif event.key() == Qt.Key_F1:
            s = ""
            s += "\nAdapt: "
            s += ["on", "off"][Colors.noAdapt]
            s += "\nAdaption occured: "
            s += ["no", "yes"][Colors.adapted]
            w = QWidget()
            s += "\nColor bit depth: %d" % w.depth()
            s += "\nWanted FPS: %d" % Colors.fps
            s += "\nBenchmarked FPS: ";
            if Colors.benchmarkFps != -1:
                s += "%d" % Colors.benchmarkFps
            else:
                s += "not calculated"
            s += "\nAnimations: ";
            s += ["on", "off"][Colors.noAnimations]
            s += "\nBlending: ";
            s += ["on", "off"][Colors.useEightBitPalette]
            s += "\nTicker: ";
            s += ["on", "off"][Colors.noTicker]
            s += "\nPixmaps: ";
            s += ["off", "on"][Colors.usePixmaps]
            s += "\nRescale images on resize: ";
            s += ["on", "off"][Colors.noRescale]
            s += "\nTimer based updates: ";
            s += ["on", "off"][Colors.noTimerUpdate]
            s += "\nSeparate loop: ";
            s += ["no", "yes"][Colors.useLoop]
            s += "\nScreen sync: ";
            s += ["yes", "no"][Colors.noScreenSync]
            QMessageBox.information(None, "Current configuration", s)

        super(MainWindow, self).keyPressEvent(event)
项目:headcache    作者:s9w    | 项目源码 | 文件源码
def keyPressEvent(self, e):
        if e.key() == Qt.Key_Escape:
            if self.finder.hasFocus():
                self.view1.setFocus()
            else:
                self.finder.setFocus()
项目:py301    作者:PFLC    | 项目源码 | 文件源码
def keyPressEvent(self, e):

        if e.key() == Qt.Key_Escape:
            self.close()
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def keyPressEvent(self, QKeyEvent):
        if QKeyEvent.key() == Qt.Key_Escape:
            pass
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def keyPressEvent(self, QKeyEvent):
        if QKeyEvent.key() == Qt.Key_Escape:
            pass
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def keyPressEvent(self, QKeyEvent):
        if QKeyEvent.key() == Qt.Key_Escape:
            pass
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def keyPressEvent(self, QKeyEvent):
        if QKeyEvent.key() == Qt.Key_Escape:
            pass
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def keyPressEvent(self, QKeyEvent):
        if QKeyEvent.key() == Qt.Key_Escape:
            pass
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def keyPressEvent(self, QKeyEvent):
        if QKeyEvent.key() == Qt.Key_Escape:
            pass
项目: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()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        """
        Prevent the user from closing the dialog using the ESC key.
        """
        if event.key() == Qt.Key_Escape:
            event.ignore()
        else:
            QDialog.keyPressEvent(self, event)
项目:songscreen    作者:maccesch    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape and self.isFullScreen():
            self.setFullScreen(False)
            event.accept()
        elif event.key() == Qt.Key_Enter and event.modifiers() & Qt.Key_Alt:
            self.setFullScreen(not self.isFullScreen())
            event.accept()
        else:
            super(VideoWidget, self).keyPressEvent(event)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            QApplication.quit()
        elif event.key() == Qt.Key_F1:
            s = ""
            s += "\nAdapt: "
            s += ["on", "off"][Colors.noAdapt]
            s += "\nAdaption occured: "
            s += ["no", "yes"][Colors.adapted]
            w = QWidget()
            s += "\nColor bit depth: %d" % w.depth()
            s += "\nWanted FPS: %d" % Colors.fps
            s += "\nBenchmarked FPS: ";
            if Colors.benchmarkFps != -1:
                s += "%d" % Colors.benchmarkFps
            else:
                s += "not calculated"
            s += "\nAnimations: ";
            s += ["on", "off"][Colors.noAnimations]
            s += "\nBlending: ";
            s += ["on", "off"][Colors.useEightBitPalette]
            s += "\nTicker: ";
            s += ["on", "off"][Colors.noTicker]
            s += "\nPixmaps: ";
            s += ["off", "on"][Colors.usePixmaps]
            s += "\nRescale images on resize: ";
            s += ["on", "off"][Colors.noRescale]
            s += "\nTimer based updates: ";
            s += ["on", "off"][Colors.noTimerUpdate]
            s += "\nSeparate loop: ";
            s += ["no", "yes"][Colors.useLoop]
            s += "\nScreen sync: ";
            s += ["yes", "no"][Colors.noScreenSync]
            QMessageBox.information(None, "Current configuration", s)

        super(MainWindow, self).keyPressEvent(event)
项目:RRPam-WDS    作者:asselapathirana    | 项目源码 | 文件源码
def test_presseing_esc_does_not_close_or_clear_the_closable_graph(self):
        dummytitle = uniquestring()
        title = uniquestring()
        self.dummy = CurveDialogWithClosable(wintitle=dummytitle, mainwindow=self.aw)
        self.aw.addSubWindow(self.dummy)
        self.graph = CurveDialogWithClosable(wintitle=title, mainwindow=self.aw)
        self.graph.setClosable(False)
        self.aw.addSubWindow(self.graph)
        self.aw.show()
        self.assertTrue(self.graph.isVisible())
        QTest.keyPress(self.graph, Qt.Key_Escape)
        self.assertTrue(self.graph.isVisible())
项目:RRPam-WDS    作者:asselapathirana    | 项目源码 | 文件源码
def test_presseing_esc_does_not_close_or_clear_the_data_window(self):
        dw = self.aw.datawindow
        self.aw.show()
        self.assertTrue(dw.isVisible())
        QTest.keyPress(dw, Qt.Key_Escape)
        self.assertTrue(dw.isVisible())
        self.aw.hide()
项目:SunFounder_PiCar-V    作者:sunfounder    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        """Keyboard press event

        Press a key on keyboard, the function will get an event, if the condition is met, call the function 
        run_action(). 
        In camera calibration mode, Effective key: W,A,S,D, ?,  ?,  ?,  ?, ESC
        In front wheel calibration mode, Effective key: A, D, ?,  ?, ESC
        In back wheel calibration mode, Effective key: A, D, ?,  ?, ESC

        Args:
            event, this argument will get when an event of keyboard pressed occured

        """
        key_press = event.key()

        if key_press in (Qt.Key_Up, Qt.Key_W):      # UP
            if   self.calibration_status == 1:
                cali_action('camcaliup')
            elif self.calibration_status == 2:
                pass
            elif self.calibration_status == 3:
                pass
        elif key_press in (Qt.Key_Right, Qt.Key_D): # RIGHT
            if   self.calibration_status == 1:
                cali_action('camcaliright')
            elif self.calibration_status == 2:
                cali_action('fwcaliright')
            elif self.calibration_status == 3:
                cali_action('bwcaliright')
        elif key_press in (Qt.Key_Down, Qt.Key_S):  # DOWN
            if   self.calibration_status == 1:
                cali_action('camcalidown')
            elif self.calibration_status == 2:
                pass
            elif self.calibration_status == 3:
                pass
        elif key_press in (Qt.Key_Left, Qt.Key_A):  # LEFT
            if   self.calibration_status == 1:
                cali_action('camcalileft')
            elif self.calibration_status == 2:
                cali_action('fwcalileft')
            elif self.calibration_status == 3:
                cali_action('bwcalileft')
                cali_action('forward')
        elif key_press == Qt.Key_Escape:            # ESC
            run_action('stop')
            self.close()