Python tk-events
|
2007, 2024 Oskar Wagner
|
class Event:
Container for the properties of an event.
Instances of this type are generated if one of the following events occurs:
Event types
- for keyboard events
KeyPress, KeyRelease
- for mouse events
ButtonPress, ButtonRelease, Motion, Enter, Leave, MouseWheel
- for window events
Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate,
Colormap, Gravity, Reparent, Property, Destroy, Activate,
Deactivate
If a callback function for one of these events is registered
using bind, bind_all, bind_class, or tag_bind,
the callback is called with an Event as first argument.
It will have the following attributes
(in braces are the event types for which
the attribute is valid):
Event attributes
- serial
- serial number of event
- num
- mouse button pressed
(ButtonPress, ButtonRelease)
- focus
- whether the window has the focus
(Enter, Leave)
- height
- height of the exposed window
(Configure, Expose)
- width
- width of the exposed window
(Configure, Expose)
- keycode
- keycode of the pressed key
(KeyPress, KeyRelease)
- state
- state of the event as a number
(ButtonPress, ButtonRelease, Enter,
KeyPress, KeyRelease, Leave, Motion)
- state
- state as a string
(Visibility)
- time
- when the event occurred
- x
- x-position of the mouse
- y
- y-position of the mouse
- x_root
- x-position of the mouse on the screen
(ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)
- y_root
- y-position of the mouse on the screen
(ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)
- char
- pressed character
(KeyPress, KeyRelease)
- send_event
- see X/Windows documentation
- keysym
- keysym of the event as a string
(KeyPress, KeyRelease)
- keysym_num
- keysym of the event as a number
(KeyPress, KeyRelease)
- type
- type of the event as a number
- widget
- widget in which the event occurred
- delta
- delta of wheel movement
(MouseWheel)
class EventType(str, enum.Enum):
KeyPress = '2'
Key = KeyPress
KeyRelease = '3'
ButtonPress = '4'
Button = ButtonPress
ButtonRelease = '5'
Motion = '6'
Enter = '7'
Leave = '8'
FocusIn = '9'
FocusOut = '10'
Keymap = '11' # undocumented
Expose = '12'
GraphicsExpose = '13' # undocumented
NoExpose = '14' # undocumented
Visibility = '15'
Create = '16'
Destroy = '17'
Unmap = '18'
Map = '19'
MapRequest = '20'
Reparent = '21'
Configure = '22'
ConfigureRequest = '23'
Gravity = '24'
ResizeRequest = '25'
Circulate = '26'
CirculateRequest = '27'
Property = '28'
SelectionClear = '29' # undocumented
SelectionRequest = '30' # undocumented
Selection = '31' # undocumented
Colormap = '32'
ClientMessage = '33' # undocumented
Mapping = '34' # undocumented
VirtualEvent = '35' # undocumented
Activate = '36'
Deactivate = '37'
MouseWheel = '38'