Package joy :: Module events
[hide private]
[frames] | no frames]

Module events

source code

joy.events defines a few utility functions for handling pygame events in the JoyApp framework. 
Because joy extends pygame with several new event types, you should use joy.event
functions to handle tasks such as printing human readable event descriptions --
the pygame builtins won't know anything about the JoyApp specific event types.

New Event Types
---------------

TIMEREVENT -- timeslice event timer for Plan execution
CKBOTPOSITION -- a CKBot moved
SCRATCHUPDATE -- a Scratch variable was updated

Main Functions
--------------
describeEvt -- describe an event in a string

Functions [hide private]
 
describeEvt(evt, parseOnly=False)
Describe an event stored in a pygame EventType object.
source code
 
JoyEvent(type_code=None, **kw)
Wrapper for pygame.Event constructor, which understands the additional event types unique to JoyApp
source code
Function Details [hide private]

describeEvt(evt, parseOnly=False)

source code 

Describe an event stored in a pygame EventType object.

Returns a human readable string that consists of all fields in the event object. These are printed in a format that makes it easy to cut and paste them into code that pattern matches events, e.g.

>>> evt = pygame.event.Event(pygame.locals.MOUSEMOTION,pos=(176, 140),rel=(0, 1),buttons=(0, 0, 0))
>>> print describeEvt(evt,0)
type==MOUSEMOTION pos==(176, 140) rel==(0, 1) buttons==(0, 0, 0)

If parseOnly is set, returns a dictionary with the extracted fields:

>>> print joy.events.describeEvt(evt,1)
{'buttons': (0, 0, 0), 'type': 'MouseMotion', 'pos': (176, 140), 'rel': (0, 1)}

JoyEvent(type_code=None, **kw)

source code 
Wrapper for pygame.Event constructor, which understands the additional
event types unique to JoyApp

INPUT: 
  type_code -- integer -- the typecode for the event type
  
OUTPUT:
  Event object, or ValueError object with error details, if failed