在pyglet中设置鼠标光标

Setting mouse cursor in pyglet

我正在尝试在 pyglet 应用程序中设置鼠标光标。根据 pyglet 文档,我应该这样做:

import pyglet

window = pyglet.window.Window()

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

pyglet.app.run()

但是,这给了我以下错误:

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

如何在不使用我自己的光标图像文件的情况下执行此操作?如果有帮助,我会加入 linux。

CURSOR_HELP 属性是您 window class 的成员。

改变

win.CURSOR_HELP

window.CURSOR_HELP

在此处找到:https://pyglet.readthedocs.io/en/pyglet-1.2-maintenance/api/pyglet/window/pyglet.window.Window.html#pyglet.window.Window.CURSOR_HELP