client.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:SunFounder_PiCar-V 作者: sunfounder 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号