简体   繁体   中英

Setting mouse cursor in pyglet

I'm trying to set the mouse cursor in a pyglet application. According to the pyglet documentation, this is how I should go about this:

import pyglet

window = pyglet.window.Window()

cursor = window.get_system_mouse_cursor(win.CURSOR_HELP)
window.set_mouse_cursor(cursor)

pyglet.app.run()

However, this gives me the following error:

cursor = window.get_system_mouse_cursor(win.CURSOR_HELP)
NameError: name 'win' is not defined

How can I do this without using my own cursor image files? I'm on linux if that helps.

The CURSOR_HELP attribute is a member of your window class.

Change

win.CURSOR_HELP

to

window.CURSOR_HELP

Found here: https://pyglet.readthedocs.io/en/pyglet-1.2-maintenance/api/pyglet/window/pyglet.window.Window.html#pyglet.window.Window.CURSOR_HELP

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM