Python PyQt5.QtCore.Qt.Key_P() Examples

The following are 4 code examples of PyQt5.QtCore.Qt.Key_P(). 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: tetris_game.py    From tetris_game with MIT License 8 votes vote down vote up
def keyPressEvent(self, event):
        if not self.isStarted or BOARD_DATA.currentShape == Shape.shapeNone:
            super(Tetris, self).keyPressEvent(event)
            return

        key = event.key()
        
        if key == Qt.Key_P:
            self.pause()
            return
            
        if self.isPaused:
            return
        elif key == Qt.Key_Left:
            BOARD_DATA.moveLeft()
        elif key == Qt.Key_Right:
            BOARD_DATA.moveRight()
        elif key == Qt.Key_Up:
            BOARD_DATA.rotateLeft()
        elif key == Qt.Key_Space:
            self.tboard.score += BOARD_DATA.dropDown()
        else:
            super(Tetris, self).keyPressEvent(event)

        self.updateWindow() 
Example #2
Source File: dataframe_viewer.py    From pandasgui with MIT License 6 votes vote down vote up
def keyPressEvent(self, event):

        QtWidgets.QWidget.keyPressEvent(self, event)

        if event.matches(QtGui.QKeySequence.Copy):
            print('Ctrl + C')
            self.dataView.copy()
        if event.matches(QtGui.QKeySequence.Paste):
            self.dataView.paste()
            print('Ctrl + V')
        if event.key() == Qt.Key_P and (event.modifiers() & Qt.ControlModifier):
            self.dataView.print()
            print('Ctrl + P')
        if event.key() == Qt.Key_D and (event.modifiers() & Qt.ControlModifier):
            self.debug()
            print('Ctrl + D') 
Example #3
Source File: Game11.py    From Games with MIT License 5 votes vote down vote up
def keyPressEvent(self, event):
		if not self.is_started or self.inner_board.current_tetris == tetrisShape().shape_empty:
			super(TetrisGame, self).keyPressEvent(event)
			return
		key = event.key()
		# P键暂停
		if key == Qt.Key_P:
			self.pause()
			return
		if self.is_paused:
			return
		# 向左
		elif key == Qt.Key_Left:
			self.inner_board.moveLeft()
		# 向右
		elif key == Qt.Key_Right:
			self.inner_board.moveRight()
		# 旋转
		elif key == Qt.Key_Up:
			self.inner_board.rotateAnticlockwise()
		# 快速坠落
		elif key == Qt.Key_Space:
			self.external_board.score += self.inner_board.dropDown()
		else:
			super(TetrisGame, self).keyPressEvent(event)
		self.updateWindow() 
Example #4
Source File: Tetris.py    From AIGames with MIT License 5 votes vote down vote up
def keyPressEvent(self, event):
		if not self.is_started or self.inner_board.current_tetris == tetrisShape().shape_empty:
			super(TetrisGame, self).keyPressEvent(event)
			return
		key = event.key()
		# P键暂停
		if key == Qt.Key_P:
			self.pause()
			return
		if self.is_paused:
			return
		else:
			super(TetrisGame, self).keyPressEvent(event)
		self.updateWindow()