当前位置: 首页>>代码示例>>Python>>正文


Python Qt.Key_Left方法代码示例

本文整理汇总了Python中PyQt5.QtCore.Qt.Key_Left方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.Key_Left方法的具体用法?Python Qt.Key_Left怎么用?Python Qt.Key_Left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.Qt的用法示例。


在下文中一共展示了Qt.Key_Left方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: keyPressEvent

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [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() 
开发者ID:LoveDaisy,项目名称:tetris_game,代码行数:27,代码来源:tetris_game.py

示例2: keyPressEvent

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def keyPressEvent(self, event: QKeyEvent) -> None:

        if self.isReadOnly():
            return

        block: QTextBlock = self.textCursor().block()

        if event.key() in [Qt.Key_Down, Qt.Key_Up, Qt.Key_Left, Qt.Key_Right]:
            return

        if not event.key() == 16777220:
            super().keyPressEvent(event)

        if not isinstance(self.ignoreLength, bool):

            textToWrite: str = block.text()[self.ignoreLength:]

            # TODO: Handle multiline input!!!

            if event.key() == 16777220:
                self.userInputSignal.emit(textToWrite)
                return 
开发者ID:CountryTk,项目名称:Hydra,代码行数:24,代码来源:Terminal.py

示例3: test_PythonProcessPane_parse_input_left_arrow

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def test_PythonProcessPane_parse_input_left_arrow(qtapp):
    """
    Left Arrow causes the cursor to move to the left one place if not at the
    start of the input line.
    """
    ppp = mu.interface.panes.PythonProcessPane()
    mock_cursor = mock.MagicMock()
    mock_cursor.position.return_value = 1
    ppp.start_of_current_line = 0
    ppp.textCursor = mock.MagicMock(return_value=mock_cursor)
    ppp.setTextCursor = mock.MagicMock()
    key = Qt.Key_Left
    text = ""
    modifiers = None
    ppp.parse_input(key, text, modifiers)
    mock_cursor.movePosition.assert_called_once_with(QTextCursor.Left)
    ppp.setTextCursor.assert_called_once_with(mock_cursor) 
开发者ID:mu-editor,项目名称:mu,代码行数:19,代码来源:test_panes.py

示例4: test_PythonProcessPane_parse_input_left_arrow_at_start_of_line

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def test_PythonProcessPane_parse_input_left_arrow_at_start_of_line(qtapp):
    """
    Left Arrow doesn't do anything if the current cursor position is at the
    start of the input line.
    """
    ppp = mu.interface.panes.PythonProcessPane()
    mock_cursor = mock.MagicMock()
    mock_cursor.position.return_value = 1
    ppp.start_of_current_line = 1
    ppp.textCursor = mock.MagicMock(return_value=mock_cursor)
    ppp.setTextCursor = mock.MagicMock()
    key = Qt.Key_Left
    text = ""
    modifiers = None
    ppp.parse_input(key, text, modifiers)
    assert mock_cursor.movePosition.call_count == 0
    assert ppp.setTextCursor.call_count == 0 
开发者ID:mu-editor,项目名称:mu,代码行数:19,代码来源:test_panes.py

示例5: init_action

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def init_action(self):
        zoom_minus = QShortcut(QKeySequence("Ctrl+-"), self)
        zoom_minus.activated.connect(self.minus)       
        zoom_plus = QShortcut(QKeySequence("Ctrl+="), self)
        zoom_plus.activated.connect(self.plus) 
        
        switch_left = QShortcut(QKeySequence(Qt.Key_Left), self)
        switch_left.activated.connect(self.left)       
        switch_right = QShortcut(QKeySequence(Qt.Key_Right), self)
        switch_right.activated.connect(self.right) 
        
        
        '''
        a1 = QAction(self)
        a1.setShortcut('Ctrl++')
        self.addAction(a1)
        a1.triggered.connect(self.plus)
        
        a2 = QAction(self)
        a2.setShortcut('Ctrl+-')
        self.addAction(a2)
        a2.triggered.connect(self.minus)
        ''' 
开发者ID:xflywind,项目名称:Python-Application,代码行数:25,代码来源:Area.py

示例6: left

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def left(self):
        self.widget.switch_page(right=False)
        
        
        
    #def keyPressEvent(self, event):
        #这里event.key()显示的是按键的编码
        #print("按下:" + str(event.key()))
        # 举例,这里Qt.Key_A注意虽然字母大写,但按键事件对大小写不敏感
        #if (event.key() == Qt.Key_Left):
        #    self.widget.switch_page(right=False)
        #elif (event.key() == Qt.Key_Right):
        #    self.widget.switch_page(right=True)
        #elif (event.modifiers() == Qt.CTRL and event.key() == Qt.Key_Plus):
        #    self.widget.zoom_book(plus=True)
        #elif (event.modifiers() == Qt.CTRL and event.key() == Qt.Key_Minus):
        #    self.widget.zoom_book(plus=False) 
开发者ID:xflywind,项目名称:Python-Application,代码行数:19,代码来源:Area.py

示例7: test_selection_cursor_left

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def test_selection_cursor_left(self, qtbot, cmd_edit):
        """Test selection persisting when moving to the first char."""
        qtbot.keyClicks(cmd_edit, ':hello')
        assert cmd_edit.text() == ':hello'
        assert cmd_edit.cursorPosition() == len(':hello')
        for _ in ':hello':
            qtbot.keyClick(cmd_edit, Qt.Key_Left, modifier=Qt.ShiftModifier)
        assert cmd_edit.cursorPosition() == len(':')
        assert cmd_edit.selectionStart() == len(':') 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:11,代码来源:test_miscwidgets.py

示例8: left

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def left(self, count=1):
        self._key_press(Qt.Key_Left, count, 'scrollBarMinimum', Qt.Horizontal) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:4,代码来源:webkittab.py

示例9: keyPressEvent

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [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() 
开发者ID:CharlesPikachu,项目名称:Games,代码行数:28,代码来源:Game11.py

示例10: _qtKeyToUMKey

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
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 
开发者ID:Ultimaker,项目名称:Uranium,代码行数:33,代码来源:QtKeyDevice.py

示例11: keyPressEvent

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def keyPressEvent(self, event: QtGui.QKeyEvent) -> None:
        key_press = event.key()
        # if key_press == Qt.Key_Up:
        #     self.snake.direction = 'u'
        # elif key_press == Qt.Key_Down:
        #     self.snake.direction = 'd'
        # elif key_press == Qt.Key_Right:
        #     self.snake.direction = 'r'
        # elif key_press == Qt.Key_Left:
        #     self.snake.direction = 'l' 
开发者ID:Chrispresso,项目名称:SnakeAI,代码行数:12,代码来源:snake_app.py

示例12: keyPressEvent

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def keyPressEvent(self, event):
        #HOT KEYS
        key = event.key()

        # Duplicate the frame step size (speed) when pressed  > or .:
        if key == Qt.Key_Greater or key == Qt.Key_Period:
            self.frame_step *= 2
            self.ui.spinBox_step.setValue(self.frame_step)
            

        # Half the frame step size (speed) when pressed: < or ,
        elif key == Qt.Key_Less or key == Qt.Key_Comma:
            self.frame_step //= 2
            if self.frame_step < 1:
                self.frame_step = 1
            self.ui.spinBox_step.setValue(self.frame_step)
            

        # Move backwards when  are pressed
        elif key == Qt.Key_Left:
            self.frame_number -= self.frame_step
            if self.frame_number < 0:
                self.frame_number = 0
            self.ui.spinBox_frame.setValue(self.frame_number)
            

        # Move forward when  are pressed
        elif key == Qt.Key_Right:
            self.frame_number += self.frame_step
            if self.frame_number >= self.tot_frames:
                self.frame_number = self.tot_frames - 1
            self.ui.spinBox_frame.setValue(self.frame_number)
            
        #super().keyPressEvent(event) 
开发者ID:ver228,项目名称:tierpsy-tracker,代码行数:36,代码来源:HDF5VideoPlayer.py

示例13: keyPressEvent

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def keyPressEvent(self, event):
        if event.modifiers() & Qt.ShiftModifier \
                and event.key() in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right]:
            dlat = 1.0 / (self.radarwidget.zoom * self.radarwidget.ar)
            dlon = 1.0 / (self.radarwidget.zoom * self.radarwidget.flat_earth)
            if event.key() == Qt.Key_Up:
                self.radarwidget.panzoom(pan=(dlat, 0.0))
            elif event.key() == Qt.Key_Down:
                self.radarwidget.panzoom(pan=(-dlat, 0.0))
            elif event.key() == Qt.Key_Left:
                self.radarwidget.panzoom(pan=(0.0, -dlon))
            elif event.key() == Qt.Key_Right:
                self.radarwidget.panzoom(pan=(0.0, dlon))

        elif event.key() == Qt.Key_Escape:
            self.closeEvent()

        elif event.key() == Qt.Key_F11:  # F11 = Toggle Full Screen mode
            if not self.isFullScreen():
                self.showFullScreen()
            else:
                self.showNormal()

        else:
            # All other events go to the BlueSky console
            self.console.keyPressEvent(event)
        event.accept() 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:29,代码来源:mainwindow.py

示例14: textChanged

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
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()) 
开发者ID:hustlei,项目名称:QssStylesheetEditor,代码行数:12,代码来源:mainwin.py

示例15: keyPressEvent

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Left [as 别名]
def keyPressEvent(self, event):
		"""Keyboard press event

		Effective key: W, A, S, D, ↑,  ↓,  ←,  →
		Press a key on keyboard, the function will get an event, if the condition is met, call the function 
		run_action(). 

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

		"""
		key_press = event.key()

		# don't need autorepeat, while haven't released, just run once
		if not event.isAutoRepeat():
			if key_press == Qt.Key_Up:			# up 
				run_action('camup')
			elif key_press == Qt.Key_Right:		# right
				run_action('camright')
			elif key_press == Qt.Key_Down:		# down
				run_action('camdown')
			elif key_press == Qt.Key_Left:		# left
				run_action('camleft')
			elif key_press == Qt.Key_W:			# W
				run_action('forward')
			elif key_press == Qt.Key_A:			# A
				run_action('fwleft')
			elif key_press == Qt.Key_S:			# S
				run_action('backward')
			elif key_press == Qt.Key_D:			# D
				run_action('fwright') 
开发者ID:sunfounder,项目名称:SunFounder_PiCar-V,代码行数:33,代码来源:client.py


注:本文中的PyQt5.QtCore.Qt.Key_Left方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。