python鼠标事件 详解_Python中pygame的mouse鼠标事件用法实例

本文介绍了Python Pygame模块中的mouse鼠标事件用法,包括获取鼠标按钮状态、位置、移动量以及设置可见性等。通过示例代码展示了如何实现鼠标事件监听,如鼠标按下、移动时改变窗口颜色。当鼠标在窗口上移动并点击时,程序会根据点击的按钮(左、右、滚轮)在控制台输出相应信息。
摘要由CSDN通过智能技术生成

本文实例讲述了Python中pygame的mouse鼠标事件用法。分享给大家供大家参考,具体如下:

pygame.mouse提供了一些方法获取鼠标设备当前的状态

‘‘‘

pygame.mouse.get_pressed - get the state of the mouse buttons get the state of the mouse buttons

pygame.mouse.get_pos - get the mouse cursor position get the mouse cursor position

pygame.mouse.get_rel - get the amount of mouse movement get the amount of mouse movement

pygame.mouse.set_pos - set the mouse cursor position set the mouse cursor position

pygame.mouse.set_visible - hide or show the mouse cursor hide or show the mouse cursor

pygame.mouse.get_focused - check if the display is receiving mouse input check if the display is receiving mouse input

pygame.mouse.set_cursor - set the image for the system mouse cursor set the image for the system mouse cursor

pygame.mouse.get_cursor - get the image for the system mouse cursor get the image for the system mouse curso

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值