Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import pyglet
  2.  
  3. #showing the main window and the main label
  4. window = pyglet.window.Window(800, 600, "Hi!")
  5. label = pyglet.text.Label('Hello world!',
  6.                           font_name='Arial',
  7.                           font_size=28,
  8.                           x=window.width//2, y=window.height//2,
  9.                           anchor_x='center', anchor_y='center')
  10.  
  11. #defining the color of the background(?)    
  12. @window.event
  13. def on_draw():
  14.     window.clear()
  15.     label.draw()
  16.  
  17. #defining what happens when you press a key
  18. def on_key_press(symbol, modifiers):
  19.     label1 = pyglet.text.Label('A key was pressed',
  20.                                font_name='Arial',
  21.                                font_size=20,
  22.                                x=window.width//2, y=window.height//2,
  23.                                anchor_x='center', anchor_y='bottom')
  24.  
  25. pyglet.app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement