今日はマウスイベントをちょっと勉強...
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pyglet
window = pyglet.window.Window(width=200, height=200, caption='Mouseev')
# MOUSE EVENTS
# mouse press
@window.event
def on_mouse_press(x, y, button, modifiers):
print('Mouse press')
print(' x: {}, y: {}, button: {}, modifiers: {}'.format(x, y, button, modifiers)
)
# mouse release
@window.event
def on_mouse_release(x, y, button, modifiers):
print('Mouse release')
print(' x: {}, y: {}, button: {}, modifiers: {}'.format(x, y, button, modifiers)
)
# mouse drag
pyglet.app.run()
ウインドウ内をクリックするとカーソル位置座標とクリックボタン名などを
返すようだ
返り値を使えばクリック座標にイメージやスプライトを配置することが
できるかもしれない
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pyglet
window = pyglet.window.Window(width=200, height=200, caption='Mouseev')
# MOUSE EVENTS
# mouse press
@window.event
def on_mouse_press(x, y, button, modifiers):
print('Mouse press')
print(' x: {}, y: {}, button: {}, modifiers: {}'.format(x, y, button, modifiers)
)
# mouse release
@window.event
def on_mouse_release(x, y, button, modifiers):
print('Mouse release')
print(' x: {}, y: {}, button: {}, modifiers: {}'.format(x, y, button, modifiers)
)
# mouse drag
pyglet.app.run()
ウインドウ内をクリックするとカーソル位置座標とクリックボタン名などを
返すようだ
返り値を使えばクリック座標にイメージやスプライトを配置することが
できるかもしれない
0 件のコメント:
コメントを投稿