Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Python Lesson 15

Events

What is an Event?

Events are signals for classes

Signals cause certain actions

What are Event Driven Programs?

  • Does nothing until an event happens

  • Runs program when event happens

What's an Event Handler?

The part of a program that handles a certain kind of event

Event Handlers Examples

  • mouseClick
  • mouseMove
  • keyDown

Event Queue

  • A list of events in the order that they have happened
  • pygame.event.get()

Let's try Key Events!

  • K_a, K_b, K_c, … (for each letter)
  • K_SPACE
  • K_ESCAPE
  • K_UP

Let's try it out!

Let's try Mouse Events!

  • MOUSEBUTTONUP
  • MOUSEBUTTONDOWN
  • MOUSEMOTION

Let's try it out!

What are Timer Events?

A timer event generates an event at regular intervals (like an alarm clock)

Let's try it out!

We can Display Text!

Use pygame.font to display text!

  • Make a font object with the font style and size
  • Render the text
  • Blit it to display it on the surface

Let's try it out!

Thank You!

Learn more about creating dynamic, engaging presentations with Prezi