在Pyglet中拖动和滚动图像

时间:2018-12-05 11:08:59

标签: python python-3.x user-interface pyglet

我是第一次使用pyglet。当我单击图像中的某处时,我想加载图像并存储坐标。我能够加载该图像,但是仅加载了一部分,并且无法滚动浏览。这是图像在窗口中的样子:

enter image description here

原始图片是这样的: full image

现在,我无法在使用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()

0 个答案:

没有答案