Skip to content

Home News Screenshots Wiki Themes Bugtracker Members Logos Search
  You are not logged in Link icon Log in Link icon Join
You are here: Home » PicoGUI Wiki » cli_python documentation » EventsModule

Log in
FrontPage » LowLevelLibrary »


The events module contains utilities for decoding ../PicoGUI events. Most of these utilities are part of the Event class, but there are two useful dictionaries - kmods, mapping mnemonic names of keyboard modifiers to the corresponding bitmask, and typenames, mapping event type codes to mnemonic names. Still, when using these to deal with events, you should rather use them trough the Event class, via the hasMod() method and the name attribute.

The Event class

Event objects have only one useful method, hasMod(), which then again only applies to keyboard events. It expects one parameter, a string describing a keyboard modifier (like "shift" or "lshift") - case is ignored - and returns true if the specified modifier was active in this event.

Most useful information is in instance attributes:

string representation of the event type, like "kbd_char" or "close"
numeric representation of the event type (don't use it unless you're very sure of what you're doing)
handle to the widget that generated the event, or None if it was a non-widget event
the undecoded parameter data. This is an int for events with EVENTCODING_PARAM or EVENTCODING_KBD and a string for EVENTCODING_DATA. In other cases it won't be present.
x and y
coordinates or size, for events where this applies.
for pointer events, the bitmask of pointer buttons that were active.
for pointer events, the bitmask of pointer buttons that changed since last event.
for keyboard events, when the event translates into a character, it is stored in this attribute. It may be either a string or unicode object.
for keyboard events, the bitmask of keyboard modifiers that were active. Don't use this unless you know what you're doing - instead, call the method hasMod().

Status: UpToDateStatus