wx.Event¶
An event is a structure holding information about an event passed to a callback or member function.
wx.Event used to be a multipurpose event object, and is an abstract base class for other event classes (see below).
For more information about events, see the Events and Event Handling overview.
Class Hierarchy¶
Known Subclasses¶
wx.ActivateEvent, wx.aui.AuiManagerEvent, wx.adv.CalculateLayoutEvent, wx.CloseEvent, wx.CommandEvent, wx.DPIChangedEvent, DialUpEvent , wx.DisplayChangedEvent, wx.DropFilesEvent, wx.EraseEvent, wx.FileSystemWatcherEvent, wx.FocusEvent, wx.FullScreenEvent, wx.GestureEvent, wx.IconizeEvent, wx.IdleEvent, wx.InitDialogEvent, wx.JoystickEvent, wx.KeyEvent, wx.MaximizeEvent, wx.MenuEvent, wx.MouseCaptureChangedEvent, wx.MouseCaptureLostEvent, wx.MouseEvent, wx.MoveEvent, wx.NavigationKeyEvent, wx.PaintEvent, wx.PaletteChangedEvent, wx.PowerEvent, wx.ProcessEvent, wx.adv.QueryLayoutInfoEvent, wx.QueryNewPaletteEvent, wx.ScrollWinEvent, wx.SetCursorEvent, wx.ShowEvent, wx.SizeEvent, SocketEvent , wx.SysColourChangedEvent, wx.adv.TaskBarIconEvent, wx.ThreadEvent, wx.TimerEvent, WebRequestEvent
Methods Summary¶
Constructor. |
|
Returns a copy of the event. |
|
Returns a generic category for this event. |
|
Returns the object (usually a window) associated with the event, if any. |
|
Returns the identifier of the given event type, such as |
|
Returns the identifier associated with this event, such as a button command id. |
|
Returns |
|
Gets the timestamp for the event. |
|
Returns |
|
Sets the propagation level to the given value (for example returned from an earlier call to |
|
Sets the originating object. |
|
Sets the event type. |
|
Sets the identifier associated with this event, such as a button command id. |
|
Sets the timestamp for the event. |
|
Test if this event should be propagated or not, i.e. if the propagation level is currently greater than 0. |
|
This method can be used inside an event handler to control whether further event handlers bound to this event will be called after the current one returns. |
|
Stop the event from propagating to its parent window. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.Event(Object)¶
Possible constructors:
Event(id=0, eventType=wxEVT_NULL) -> None
An event is a structure holding information about an event passed to a callback or member function.
Methods¶
- __init__(self, id=0, eventType=wxEVT_NULL)¶
Constructor.
Notice that events are usually created by wxWidgets itself and creating e.g. a wx.PaintEvent in your code and sending it to e.g. a wx.TextCtrl will not usually affect it at all as native controls have no specific knowledge about wxWidgets events. However you may construct objects of specific types and pass them to
wx.EvtHandler.ProcessEvent
if you want to create your own custom control and want to process its events in the same manner as the standard ones.Also please notice that the order of parameters in this constructor is different from almost all the derived classes which specify the event type as the first argument.
- Parameters:
id (int) – The identifier of the object (window, timer, …) which generated this event.
eventType (wx.EventType) – The unique type of event, e.g.
wxEVT_PAINT
,wxEVT_SIZE
orwxEVT_BUTTON
.
- Return type:
None
- Clone(self)¶
Returns a copy of the event.
Any event that is posted to the wxWidgets event system for later action (via
wx.EvtHandler.AddPendingEvent
,wx.EvtHandler.QueueEvent
orwx.PostEvent
) must implement this method.All wxWidgets events fully implement this method, but any derived events implemented by the user should also implement this method just in case they (or some event derived from them) are ever posted.
All wxWidgets events implement a copy constructor, so the easiest way of implementing the Clone function is to implement a copy constructor for a new event (call it MyEvent) and then define the Clone function like this:
def Clone(self): return MyEvent()
- Return type:
- GetEventCategory(self)¶
Returns a generic category for this event.
wx.Event implementation returns
wxEVT_CATEGORY_UI
by default.This function is used to selectively process events in
wx.EventLoopBase.YieldFor
.- Return type:
- GetEventObject(self)¶
Returns the object (usually a window) associated with the event, if any.
- Return type:
- GetEventType(self)¶
Returns the identifier of the given event type, such as
wxEVT_BUTTON
.- Return type:
wx.EventType
- GetId(self)¶
Returns the identifier associated with this event, such as a button command id.
- Return type:
int
- GetSkipped(self)¶
Returns
True
if the event handler should be skipped,False
otherwise.- Return type:
bool
- GetTimestamp(self)¶
Gets the timestamp for the event.
The timestamp is the time in milliseconds since some fixed moment (not necessarily the standard Unix Epoch, so only differences between the timestamps and not their absolute values usually make sense).
- Return type:
int
Warning
wxWidgets returns a not
None
timestamp only for mouse and key events (see wx.MouseEvent and wx.KeyEvent).
- IsCommandEvent(self)¶
Returns
True
if the event is or is derived from wx.CommandEvent else it returnsFalse
.- Return type:
bool
Note
exists only for optimization purposes.
- ResumePropagation(self, propagationLevel)¶
Sets the propagation level to the given value (for example returned from an earlier call to
wx.Event.StopPropagation
).- Parameters:
propagationLevel (int)
- Return type:
None
- SetEventObject(self, object)¶
Sets the originating object.
- Parameters:
object (wx.Object)
- Return type:
None
- SetEventType(self, type)¶
Sets the event type.
- Parameters:
type (wx.EventType)
- Return type:
None
- SetId(self, id)¶
Sets the identifier associated with this event, such as a button command id.
- Parameters:
id (int)
- Return type:
None
- SetTimestamp(self, timeStamp=0)¶
Sets the timestamp for the event.
- Parameters:
timeStamp (long)
- Return type:
None
- ShouldPropagate(self)¶
Test if this event should be propagated or not, i.e. if the propagation level is currently greater than 0.
- Return type:
bool
- Skip(self, skip=True)¶
This method can be used inside an event handler to control whether further event handlers bound to this event will be called after the current one returns.
Without
Skip
(or equivalently if Skip(false) is used), the event will not be processed any more. If Skip(true) is called, the event processing system continues searching for a further handler function for this event, even though it has been processed already in the current handler.In general, it is recommended to skip all non-command events to allow the default handling to take place. The command events are, however, normally not skipped as usually a single command such as a button click or menu item selection must only be processed by one handler.
- Parameters:
skip (bool)
- Return type:
None
- StopPropagation(self)¶
Stop the event from propagating to its parent window.
Returns the old propagation level value which may be later passed to
ResumePropagation
to allow propagating the event again.- Return type:
int
Properties¶
- EventObject¶
See
GetEventObject
andSetEventObject
- EventType¶
See
GetEventType
andSetEventType
- Skipped¶
See
GetSkipped
- Timestamp¶
See
GetTimestamp
andSetTimestamp