.. 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.adv.NotificationMessage:

==========================================================================================================================================
|phoenix_title|  **wx.adv.NotificationMessage**
==========================================================================================================================================

This class allows showing the user a message non intrusively.          

Currently it is implemented natively for Windows, macOS, GTK and uses generic toast notifications under the other platforms. It's not recommended but  ``GenericNotificationMessage``   can be used instead of the native ones. This might make sense if your application requires features not available in the native implementation. 

Notice that this class is not a window and so doesn't derive from :ref:`wx.Window`. 



|phoenix_title| Platform Notes
==============================



Windows
-------

Up to Windows 8 balloon notifications are displayed from an icon in the notification area of the taskbar. If your application uses a :ref:`wx.adv.TaskBarIcon`  you should call :meth:`~wx.adv.NotificationMessage.UseTaskBarIcon`  to ensure that only one icon is shown in the notification area. Windows 10 displays all notifications as popup toasts. To suppress the additional icon in the notification area on Windows 10 and for toast notification support on Windows 8 it is recommended to call :meth:`~wx.adv.NotificationMessage.MSWUseToasts`  before showing the first notification message.  



macOS
-----

The macOS implementation uses Notification Center to display native notifications. In order to use actions your notifications must use the alert style. This can be enabled by the user in system settings or by setting the  ``NSUserNotificationAlertStyle``   value in Info.plist to   ``alert`` . Please note that the user always has the option to change the notification style.  





.. _NotificationMessage-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive one of the :ref:`wx.CommandEvent` parameters.

- wxEVT_NOTIFICATION_MESSAGE_CLICK: Process a  ``wxEVT_NOTIFICATION_MESSAGE_CLICK``   event, when a notification is clicked.   
- wxEVT_NOTIFICATION_MESSAGE_DISMISSED: Process a  ``wxEVT_NOTIFICATION_MESSAGE_DISMISSED``   event, when a notification is dismissed by the user or times out.   
- wxEVT_NOTIFICATION_MESSAGE_ACTION: Process a  ``wxEVT_NOTIFICATION_MESSAGE_ACTION``   event, when the user selects on of the actions added by  :meth:`~wx.adv.NotificationMessage.AddAction`   


:ref:`Core`   



.. versionadded:: 2.9.0 
     







|

|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>NotificationMessage</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.adv.NotificationMessage_inheritance.png" alt="Inheritance diagram of NotificationMessage" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.adv.NotificationMessage.html" title="wx.adv.NotificationMessage" alt="" coords="7,160,211,189"/> <area shape="rect" id="node2" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="50,83,167,112"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> <area shape="rect" id="node4" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="117,5,223,35"/> </map> 
   </p>
   </div>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.adv.NotificationMessage.__init__`                                     Default constructor, use :meth:`~NotificationMessage.SetParent` , :meth:`~NotificationMessage.SetTitle`   and :meth:`~NotificationMessage.SetMessage`   to initialize the object before showing it.
:meth:`~wx.adv.NotificationMessage.AddAction`                                    Add an action to the notification.
:meth:`~wx.adv.NotificationMessage.Close`                                        Hides the notification.
:meth:`~wx.adv.NotificationMessage.MSWUseToasts`                                 Enables toast notifications available since Windows 8 and suppresses the additional icon in the notification area on Windows 10.
:meth:`~wx.adv.NotificationMessage.SetFlags`                                     This parameter can be currently used to specify the icon to show in the notification.
:meth:`~wx.adv.NotificationMessage.SetIcon`                                      Specify a custom icon to be displayed in the notification.
:meth:`~wx.adv.NotificationMessage.SetMessage`                                   Set the main text of the notification.
:meth:`~wx.adv.NotificationMessage.SetParent`                                    Set the parent for this notification: the notification will be associated with the top level parent of this window or, if this method is not called, with the main application window by default.
:meth:`~wx.adv.NotificationMessage.SetTitle`                                     Set the title, it must be a concise string (not more than 64 characters), use :meth:`~NotificationMessage.SetMessage`   to give the user more details.
:meth:`~wx.adv.NotificationMessage.Show`                                         Show the notification to the user and hides it after `timeout`  seconds are elapsed.
:meth:`~wx.adv.NotificationMessage.UseTaskBarIcon`                               If the application already uses a :ref:`wx.adv.TaskBarIcon`, it should be connected to notifications by using this method.
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.adv.NotificationMessage(EvtHandler)

   **Possible constructors**::

       NotificationMessage()
       
       NotificationMessage(title, message="", parent=None,
                           flags=ICON_INFORMATION)
       
   
   This class allows showing the user a message non intrusively.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self)`
      
      Default constructor, use :meth:`SetParent` , :meth:`SetTitle`   and :meth:`SetMessage`   to initialize the object before showing it.                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, title, message=EmptyString, parent=None, flags=ICON_INFORMATION)`
      
      Create a notification object with the given attributes.                  
      
      See :meth:`SetTitle` , :meth:`SetMessage` , :meth:`SetParent`   and :meth:`SetFlags`   for the description of the corresponding parameters.                  
      
      
      :param `title`: 
      :type `title`: string
      :param `message`: 
      :type `message`: string
      :param `parent`: 
      :type `parent`: wx.Window
      :param `flags`: 
      :type `flags`: int
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: AddAction(self, actionid, label="")

      Add an action to the notification.                  

      If supported by the implementation this are usually buttons in the notification selectable by the user. 

                


      :param `actionid`: 
      :type `actionid`: wx.WindowID
      :param `label`: 
      :type `label`: string




      :rtype: `bool`







      :returns: 

         ``False`` if the current implementation or OS version does not support actions in notifications.  







      .. versionadded:: 4.1/wxWidgets-3.1.0  
     








   .. method:: Close(self)

      Hides the notification.                  

      Returns ``True`` if it was hidden or ``False`` if it couldn't be done (e.g. on some systems automatically hidden notifications can't be hidden manually).                  

      :rtype: `bool`








   .. staticmethod:: MSWUseToasts(shortcutPath="", appId="")

      Enables toast notifications available since Windows 8 and suppresses the additional icon in the notification area on Windows 10.                  

      Toast notifications **require**  a shortcut to the application in the start menu. The start menu shortcut needs to contain an Application User Model ``ID``. It is recommended that the applications setup creates the shortcut and the application specifies the setup created shortcut in  ``shortcutPath`` . A call to this method will verify (and if necessary modify) the shortcut before enabling toast notifications. 




      :param `shortcutPath`: Path to a shortcut file referencing the applications executable. If the string is empty the applications display name will be used. If not fully qualified, it will be used as a path relative to the users start menu directory. The file extension .lnk is optional.   
      :type `shortcutPath`: string
      :param `appId`: The applications `Application User Model ID <https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(vs.85).aspx>`_. If empty it will be extracted from the shortcut. If the shortcut does not contain an id an id will be automatically created from the applications vendor and app name.  
      :type `appId`: string








      :rtype: `bool`






                 



      :returns: 

         ``False`` if toast notifications could not be enabled.  







      .. versionadded:: 4.1/wxWidgets-3.1.0  
     







      .. availability:: Only available for MSW.  







      .. seealso:: :meth:`wx.AppConsole.SetAppName` , :meth:`wx.AppConsole.SetVendorName`   








   .. method:: SetFlags(self, flags)

      This parameter can be currently used to specify the icon to show in the notification.                  

      Valid values are  ``ICON_INFORMATION`` ,   ``ICON_WARNING``   and   ``ICON_ERROR``   (notice that   ``ICON_QUESTION``   is not allowed here). Some implementations of this class may not support the icons. 

                


      :param `flags`: 
      :type `flags`: int






      .. seealso:: :meth:`SetIcon`     








   .. method:: SetIcon(self, icon)

      Specify a custom icon to be displayed in the notification.                  

      Some implementations of this class may not support custom icons. 

                


      :param `icon`: 
      :type `icon`: wx.Icon






      .. versionadded:: 4.1/wxWidgets-3.1.0  
     







      .. seealso:: :meth:`SetFlags`   








   .. method:: SetMessage(self, message)

      Set the main text of the notification.                  

      This should be a more detailed description than the title but still limited to reasonable length (not more than 256 characters).                  


      :param `message`: 
      :type `message`: string







   .. method:: SetParent(self, parent)

      Set the parent for this notification: the notification will be associated with the top level parent of this window or, if this method is not called, with the main application window by default.                  


      :param `parent`: 
      :type `parent`: wx.Window







   .. method:: SetTitle(self, title)

      Set the title, it must be a concise string (not more than 64 characters), use :meth:`SetMessage`   to give the user more details.                  


      :param `title`: 
      :type `title`: string







   .. method:: Show(self, timeout=Timeout_Auto)

      Show the notification to the user and hides it after `timeout`  seconds are elapsed.                  

      Special values  ``Timeout_Auto``   and   ``Timeout_Never``   can be used here, notice that you shouldn't rely on  `timeout`  being exactly respected because the current platform may only support default timeout value and also because the user may be able to close the notification. 

                


      :param `timeout`: 
      :type `timeout`: int




      :rtype: `bool`







      :returns: 

         ``False`` if an error occurred.   







      .. note:: 

         When using native notifications in wxGTK, the timeout is ignored for the notifications with  ``ICON_WARNING``   or   ``ICON_ERROR``   flags, they always remain shown unless they're explicitly hidden by the user, i.e. behave as if Timeout_Auto were given.  








   .. staticmethod:: UseTaskBarIcon(icon)

      If the application already uses a :ref:`wx.adv.TaskBarIcon`, it should be connected to notifications by using this method.                  

      This has no effect if toast notifications are used. 





      :param `icon`: 
      :type `icon`: wx.adv.TaskBarIcon




      :rtype: :ref:`wx.adv.TaskBarIcon`







      :returns: 

         the task bar icon which was used previously (may be  ``NULL`` )  







      .. availability:: Only available for MSW.  







