本文整理汇总了Python中PyQt5.QtCore.Qt.Key_P方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.Key_P方法的具体用法?Python Qt.Key_P怎么用?Python Qt.Key_P使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.Key_P方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_P [as 别名]
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()
示例2: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_P [as 别名]
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')
示例3: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_P [as 别名]
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()
示例4: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_P [as 别名]
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()