Skip to content

Instantly share code, notes, and snippets.

@encukou
Created January 8, 2021 22:40
Show Gist options
  • Save encukou/6b0ed226f1c5c851174d67fb7753971b to your computer and use it in GitHub Desktop.
Save encukou/6b0ed226f1c5c851174d67fb7753971b to your computer and use it in GitHub Desktop.
# pip install pyglet
import pyglet
window = pyglet.window.Window(
style=pyglet.window.Window.WINDOW_STYLE_BORDERLESS,
resizable=True,
)
label = pyglet.text.Label('Zavřít ', font_name=['Fira Mono', 'Courier New'])
@window.event
def on_draw():
window.clear()
label.x = window.width - label.content_width
label.y = window.height - label.content_height
label.draw()
def in_label(x, y):
return (
x > window.width - label.content_width
and y > window.height - label.content_height
)
@window.event
def on_mouse_motion(x, y, dx, dy):
if in_label(x, y):
label.color = 0, 255, 0, 255
else:
label.color = 255, 255, 255, 255
@window.event
def on_mouse_release(x, y, button, mod):
if in_label(x, y):
window.close()
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment