我是第一次使用pyglet
。当我单击图像中的某处时,我想加载图像并存储坐标。我能够加载该图像,但是仅加载了一部分,并且无法滚动浏览。这是图像在窗口中的样子:
现在,我无法在使用Pyglet创建的窗口中滚动和拖动。谁能让我知道如何修改此代码以实现相同的目的?
import pyglet
from pyglet.window import mouse
window = pyglet.window.Window(fullscreen=False)
@window.event
def on_draw():
window.clear()
image.blit(0, 0)
@window.event
def on_mouse_press(x, y, button, modifiers):
if button == mouse.LEFT:
print("Left mouse button pressed at: ", x, y)
elif button==mouse.RIGHT:
print("Right mouse button pressed at: ", x, y)
else:
"Oh no, you did nothing!!"
@window.event
def on_close():
print("Closing the current workspace")
@window.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
pass
@window.event
def on_mouse_scroll(x, y, scroll_x, scroll_y):
pass
@window.event
def on_mouse_enter(x, y):
pass
@window.event
def on_mouse_leave(x, y):
pass
image = pyglet.resource.image('cat.jpg')
window.set_exclusive_mouse(False)
window.set_mouse_visible(True)
pyglet.app.run()