.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2017 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 <events and event handling>`  overview. 





|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>Event</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.Event_inheritance.png" alt="Inheritance diagram of Event" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Event.html" title="wx.Event" alt="" coords="6,83,84,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="4,5,85,35"/> </map> 
   </p>

|


|sub_classes| Known Subclasses
==============================

:ref:`wx.ActivateEvent`, :ref:`wx.aui.AuiManagerEvent`, :ref:`wx.adv.CalculateLayoutEvent`, :ref:`wx.CloseEvent`, :ref:`wx.CommandEvent`, :ref:`DialUpEvent`, :ref:`wx.DisplayChangedEvent`, :ref:`wx.DropFilesEvent`, :ref:`wx.EraseEvent`, :ref:`wx.FileSystemWatcherEvent`, :ref:`wx.FocusEvent`, :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`, :ref:`SocketEvent`, :ref:`wx.SysColourChangedEvent`, :ref:`wx.adv.TaskBarIconEvent`, :ref:`ThreadEvent`, :ref:`wx.TimerEvent`

|


|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.GetEventUserData`                                               Return the user data associated with a dynamically connected event handler.
: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 :ref:`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: :ref:`wx.EventType`








   .. method:: GetEventUserData(self)

      Return the user data associated with a dynamically connected event handler.                  

      :meth:`wx.EvtHandler.Connect`   and :meth:`wx.EvtHandler.Bind`   allow associating optional  ``userData``   pointer with the handler and this method returns the value of this pointer. 

      The returned pointer is owned by wxWidgets and must not be deleted. 

                

      :rtype: :ref:`wx.Object`







      .. versionadded:: 2.9.5 
     








   .. 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 non-NULL 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`

