tdl.event
index
c:\users\kyle\dropbox\python\python-tdl\tdl\event.py

This module handles user input.
 
Here's a quick reference to Event types and their attributes:
QUIT
KEYDOWN: keyname key char alt ctrl shift lalt lctrl ralt rctrl
KEYUP: keyname key char alt ctrl shift lalt lctrl ralt rctrl
MOUSEDOWN: button pos cell
MOUSEUP: button pos cell
MOUSEMOTION: pos cell motion cellmotion
 
You will likely want to use the tdl.event.get function but you can still
use keyWait and isWindowClosed to control your entire program.

 
Modules
       
tdl.tcod
ctypes

 
Classes
       
__builtin__.object
Event
KeyEvent
KeyDown
KeyUp
MouseButtonEvent
MouseDown
MouseUp
MouseMotion
Quit

 
class Event(__builtin__.object)
     Methods defined here:
__repr__(self)

Data and other attributes defined here:
type = None

 
class KeyDown(KeyEvent)
    
Method resolution order:
KeyDown
KeyEvent
Event
__builtin__.object

Data and other attributes defined here:
type = 'KEYDOWN'

Methods inherited from KeyEvent:
__init__(self, key, char, lalt, lctrl, ralt, rctrl, shift)

Data descriptors inherited from KeyEvent:
alt
char
ctrl
key
keyname
lalt
lctrl
ralt
rctrl
shift

Methods inherited from Event:
__repr__(self)

 
class KeyEvent(Event)
    
Method resolution order:
KeyEvent
Event
__builtin__.object

Methods defined here:
__init__(self, key, char, lalt, lctrl, ralt, rctrl, shift)

Data descriptors defined here:
alt
char
ctrl
key
keyname
lalt
lctrl
ralt
rctrl
shift

Methods inherited from Event:
__repr__(self)

Data and other attributes inherited from Event:
type = None

 
class KeyUp(KeyEvent)
    
Method resolution order:
KeyUp
KeyEvent
Event
__builtin__.object

Data and other attributes defined here:
type = 'KEYUP'

Methods inherited from KeyEvent:
__init__(self, key, char, lalt, lctrl, ralt, rctrl, shift)

Data descriptors inherited from KeyEvent:
alt
char
ctrl
key
keyname
lalt
lctrl
ralt
rctrl
shift

Methods inherited from Event:
__repr__(self)

 
class MouseButtonEvent(Event)
    
Method resolution order:
MouseButtonEvent
Event
__builtin__.object

Methods defined here:
__init__(self, button, pos, cell)

Data descriptors defined here:
button
cell
pos

Methods inherited from Event:
__repr__(self)

Data and other attributes inherited from Event:
type = None

 
class MouseDown(MouseButtonEvent)
    
Method resolution order:
MouseDown
MouseButtonEvent
Event
__builtin__.object

Data and other attributes defined here:
type = 'MOUSEDOWN'

Methods inherited from MouseButtonEvent:
__init__(self, button, pos, cell)

Data descriptors inherited from MouseButtonEvent:
button
cell
pos

Methods inherited from Event:
__repr__(self)

 
class MouseMotion(Event)
    
Method resolution order:
MouseMotion
Event
__builtin__.object

Methods defined here:
__init__(self, pos, cell, motion, cellmotion)

Data descriptors defined here:
cell
cellmotion
motion
pos

Data and other attributes defined here:
type = 'MOUSEMOTION'

Methods inherited from Event:
__repr__(self)

 
class MouseUp(MouseButtonEvent)
    
Method resolution order:
MouseUp
MouseButtonEvent
Event
__builtin__.object

Data and other attributes defined here:
type = 'MOUSEUP'

Methods inherited from MouseButtonEvent:
__init__(self, button, pos, cell)

Data descriptors inherited from MouseButtonEvent:
button
cell
pos

Methods inherited from Event:
__repr__(self)

 
class Quit(Event)
    
Method resolution order:
Quit
Event
__builtin__.object

Data and other attributes defined here:
type = 'QUIT'

Methods inherited from Event:
__repr__(self)

 
Functions
       
get()
Flushes the event queue and returns the list of events.
 
This function returns Event objects that can be ID'd and sorted with their type attribute:
for event in tdl.event.get():
    if event.type == 'QUIT':
        raise SystemExit()
    elif event.type == 'MOUSEDOWN':
        print('Mouse button %i clicked at %i, %i' % (event.button, event.pos[0], event.pos[1]))
    elif event.type == 'KEYDOWN':
        print('Key #%i "%s" pressed' % (event.key, event.char))
 
Here is a list of events and their attributes:
QUIT
KEYDOWN: key char keyname alt ctrl shift lalt lctrl ralt rctrl
KEYUP: key char keyname alt ctrl shift lalt lctrl ralt rctrl
MOUSEDOWN: button pos cell
MOUSEUP: button pos cell
MOUSEMOTION: pos motion cell cellmotion
isWindowClosed()
Returns True if the exit button on the window has been clicked and
stays True afterwards.
keyWait()
Waits until the user presses a key.  Then returns a KeyDown event.

 
Data
        __all__ = ['Quit', 'MouseUp', 'KeyDown', 'keyWait', 'MouseMotion', 'MouseButtonEvent', 'isWindowClosed', 'get', 'MouseDown', 'KeyEvent', 'KeyUp', 'ctypes', 'Event']