I suppose with a name like Pygame its easy to think its only for games, but its actually a wrapper around the Simple DirectMedia Layer API, or SDL library for short. There are other libraries that can also do the same, like Pyglet or WxPython, among others. In Pyglet you can draw the mouse as an icon using its captured coordinates and move it around, for example:
import pyglet
from pyglet.window import mouse
class Example(pyglet.window.Window):
def __init__(self):
super(Example, self).__init__(640, 480, resizable=False, fullscreen=False, caption="Example")
## self.set_exclusive_mouse(True)
self.clear()
#mouse cursor position
self.mouse = [0,0]
pyglet.clock.schedule_interval(self.update, .01)
def update(self,dt):
#purge mouse clicks
if len(self.mouse) > 2:
self.mouse = self.mouse[:2]
#draw screen
self.draw()
def draw(self):
self.clear()
#If you set exclusive mouse you can draw the mouse with an image
#using the mouses current position for example:
#self.icon.blit(self.mouse[0],self.mouse[1])
#Mouse Motion Input
def on_mouse_motion(self,x,y,dx,dy):
self.mouse[0] += dx
self.mouse[1] += dy
#Mouse Drag Input
def on_mouse_drag(self,x,y,dx,dy,buttons,modifiers):
self.mouse[0] += dx
self.mouse[1] += dy
#Mouse Press Input
def on_mouse_press(self,x,y,button,modifiers):
self.mouse.append(mouse.buttons_string(button) + " press")
#Mouse Release Input
def on_mouse_release(self,x,y,button,modifiers):
self.mouse.append(mouse.buttons_string(button) + " release")
if __name__ == '__main__':
window = Example()
pyglet.app.run()
You can also do the same in WxPython by using Get Mouse Position and Warp Pointer:
import wx
class Frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='Example', pos=(150,150), size=(350,200))
#get the mouses current coordinates relative to the windows upper left corner
print self.ScreenToClient(wx.GetMousePosition())
#move mouse to the upper left of the window
self.WarpPointer(0,0)
app = wx.App()
top = Frame()
top.Show()
app.MainLoop()
-
BrushTone v1.3.3: Accessible Paint Tool
-
AudiMesh3D v1.0.0: Accessible 3D Model Viewer