.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.Event: ========================================================================================================================================== |phoenix_title| **wx.Event** ========================================================================================================================================== An event is a structure holding information about an event passed to a callback or member function. :ref:`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 :ref:`Events and Event Handling ` overview. | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class Event:
| |sub_classes| Known Subclasses ============================== :ref:`wx.ActivateEvent`, :ref:`wx.aui.AuiManagerEvent`, :ref:`wx.adv.CalculateLayoutEvent`, :ref:`wx.CloseEvent`, :ref:`wx.CommandEvent`, `DialUpEvent` , :ref:`wx.DisplayChangedEvent`, :ref:`wx.DPIChangedEvent`, :ref:`wx.DropFilesEvent`, :ref:`wx.EraseEvent`, :ref:`wx.FileSystemWatcherEvent`, :ref:`wx.FocusEvent`, :ref:`wx.FullScreenEvent`, :ref:`wx.GestureEvent`, :ref:`wx.IconizeEvent`, :ref:`wx.IdleEvent`, :ref:`wx.InitDialogEvent`, :ref:`wx.JoystickEvent`, :ref:`wx.KeyEvent`, :ref:`wx.MaximizeEvent`, :ref:`wx.MenuEvent`, :ref:`wx.MouseCaptureChangedEvent`, :ref:`wx.MouseCaptureLostEvent`, :ref:`wx.MouseEvent`, :ref:`wx.MoveEvent`, :ref:`wx.NavigationKeyEvent`, :ref:`wx.PaintEvent`, :ref:`wx.PaletteChangedEvent`, :ref:`wx.PowerEvent`, :ref:`wx.ProcessEvent`, :ref:`wx.adv.QueryLayoutInfoEvent`, :ref:`wx.QueryNewPaletteEvent`, :ref:`wx.ScrollWinEvent`, :ref:`wx.SetCursorEvent`, :ref:`wx.ShowEvent`, :ref:`wx.SizeEvent`, `SocketEvent` , :ref:`wx.SysColourChangedEvent`, :ref:`wx.adv.TaskBarIconEvent`, :ref:`wx.ThreadEvent`, :ref:`wx.TimerEvent`, `WebRequestEvent` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.Event.__init__` Constructor. :meth:`~wx.Event.Clone` Returns a copy of the event. :meth:`~wx.Event.GetEventCategory` Returns a generic category for this event. :meth:`~wx.Event.GetEventObject` Returns the object (usually a window) associated with the event, if any. :meth:`~wx.Event.GetEventType` Returns the identifier of the given event type, such as ``wxEVT_BUTTON`` . :meth:`~wx.Event.GetId` Returns the identifier associated with this event, such as a button command id. :meth:`~wx.Event.GetSkipped` Returns ``True`` if the event handler should be skipped, ``False`` otherwise. :meth:`~wx.Event.GetTimestamp` Gets the timestamp for the event. :meth:`~wx.Event.IsCommandEvent` Returns ``True`` if the event is or is derived from :ref:`wx.CommandEvent` else it returns ``False``. :meth:`~wx.Event.ResumePropagation` Sets the propagation level to the given value (for example returned from an earlier call to :meth:`wx.Event.StopPropagation` ). :meth:`~wx.Event.SetEventObject` Sets the originating object. :meth:`~wx.Event.SetEventType` Sets the event type. :meth:`~wx.Event.SetId` Sets the identifier associated with this event, such as a button command id. :meth:`~wx.Event.SetTimestamp` Sets the timestamp for the event. :meth:`~wx.Event.ShouldPropagate` Test if this event should be propagated or not, i.e. if the propagation level is currently greater than 0. :meth:`~wx.Event.Skip` 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. :meth:`~wx.Event.StopPropagation` Stop the event from propagating to its parent window. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.Event.EventObject` See :meth:`~wx.Event.GetEventObject` and :meth:`~wx.Event.SetEventObject` :attr:`~wx.Event.EventType` See :meth:`~wx.Event.GetEventType` and :meth:`~wx.Event.SetEventType` :attr:`~wx.Event.Id` See :meth:`~wx.Event.GetId` and :meth:`~wx.Event.SetId` :attr:`~wx.Event.Skipped` See :meth:`~wx.Event.GetSkipped` :attr:`~wx.Event.Timestamp` See :meth:`~wx.Event.GetTimestamp` and :meth:`~wx.Event.SetTimestamp` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.Event(Object) **Possible constructors**:: Event(id=0, eventType=wxEVT_NULL) An event is a structure holding information about an event passed to a callback or member function. .. method:: __init__(self, id=0, eventType=wxEVT_NULL) Constructor. Notice that events are usually created by wxWidgets itself and creating e.g. a :ref:`wx.PaintEvent` in your code and sending it to e.g. a :ref:`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 :meth:`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. :param `id`: The identifier of the object (window, timer, ...) which generated this event. :type `id`: int :param `eventType`: The unique type of event, e.g. ``wxEVT_PAINT`` , ``wxEVT_SIZE`` or ``wxEVT_BUTTON`` . :type `eventType`: wx.EventType .. method:: Clone(self) Returns a copy of the event. Any event that is posted to the wxWidgets event system for later action (via :meth:`wx.EvtHandler.AddPendingEvent` , :meth:`wx.EvtHandler.QueueEvent` or `wx.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() :rtype: :ref:`wx.Event` .. method:: GetEventCategory(self) Returns a generic category for this event. :ref:`wx.Event` implementation returns ``wxEVT_CATEGORY_UI`` by default. This function is used to selectively process events in :meth:`wx.EventLoopBase.YieldFor` . :rtype: :ref:`wx.EventCategory` .. method:: GetEventObject(self) Returns the object (usually a window) associated with the event, if any. :rtype: :ref:`wx.Object` .. method:: GetEventType(self) Returns the identifier of the given event type, such as ``wxEVT_BUTTON`` . :rtype: `wx.EventType` .. method:: GetId(self) Returns the identifier associated with this event, such as a button command id. :rtype: `int` .. method:: GetSkipped(self) Returns ``True`` if the event handler should be skipped, ``False`` otherwise. :rtype: `bool` .. method:: 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). :rtype: `long` .. warning:: wxWidgets returns a not ``None`` timestamp only for mouse and key events (see :ref:`wx.MouseEvent` and :ref:`wx.KeyEvent`). .. method:: IsCommandEvent(self) Returns ``True`` if the event is or is derived from :ref:`wx.CommandEvent` else it returns ``False``. :rtype: `bool` .. note:: exists only for optimization purposes. .. method:: ResumePropagation(self, propagationLevel) Sets the propagation level to the given value (for example returned from an earlier call to :meth:`wx.Event.StopPropagation` ). :param `propagationLevel`: :type `propagationLevel`: int .. method:: SetEventObject(self, object) Sets the originating object. :param `object`: :type `object`: wx.Object .. method:: SetEventType(self, type) Sets the event type. :param `type`: :type `type`: wx.EventType .. method:: SetId(self, id) Sets the identifier associated with this event, such as a button command id. :param `id`: :type `id`: int .. method:: SetTimestamp(self, timeStamp=0) Sets the timestamp for the event. :param `timeStamp`: :type `timeStamp`: long .. method:: ShouldPropagate(self) Test if this event should be propagated or not, i.e. if the propagation level is currently greater than 0. :rtype: `bool` .. method:: 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 :meth:`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. :param `skip`: :type `skip`: bool .. method:: StopPropagation(self) Stop the event from propagating to its parent window. Returns the old propagation level value which may be later passed to :meth:`ResumePropagation` to allow propagating the event again. :rtype: `int` .. attribute:: EventObject See :meth:`~wx.Event.GetEventObject` and :meth:`~wx.Event.SetEventObject` .. attribute:: EventType See :meth:`~wx.Event.GetEventType` and :meth:`~wx.Event.SetEventType` .. attribute:: Id See :meth:`~wx.Event.GetId` and :meth:`~wx.Event.SetId` .. attribute:: Skipped See :meth:`~wx.Event.GetSkipped` .. attribute:: Timestamp See :meth:`~wx.Event.GetTimestamp` and :meth:`~wx.Event.SetTimestamp`