.. wxPython Phoenix documentation

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

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.AnyButton:

==========================================================================================================================================
|phoenix_title|  **wx.AnyButton**
==========================================================================================================================================

A class for common button functionality used as the base for the various button classes.           




|

|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>AnyButton</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.AnyButton_inheritance.png" alt="Inheritance diagram of AnyButton" 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.Control.html" title="wx.Control" alt="" coords="60,237,148,267"/> <area shape="rect" id="node6" href="wx.AnyButton.html" title="wx.AnyButton" alt="" coords="49,315,159,344"/> <area shape="rect" id="node2" href="wx.Window.html" title="wx.Window" alt="" coords="59,160,148,189"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,87,35"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="48,83,159,112"/> <area shape="rect" id="node5" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="112,5,213,35"/> </map> 
   </p>

|


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

:ref:`wx.Button`, :ref:`wx.ToggleButton`

|


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

================================================================================ ================================================================================
:meth:`~wx.AnyButton.__init__`                                                   
:meth:`~wx.AnyButton.GetBitmap`                                                  Return the bitmap shown by the button.
:meth:`~wx.AnyButton.GetBitmapCurrent`                                           Returns the bitmap used when the mouse is over the button, which may be invalid.
:meth:`~wx.AnyButton.GetBitmapDisabled`                                          Returns the bitmap for the disabled state, which may be invalid.
:meth:`~wx.AnyButton.GetBitmapFocus`                                             Returns the bitmap for the focused state, which may be invalid.
:meth:`~wx.AnyButton.GetBitmapLabel`                                             Returns the bitmap for the normal state.
:meth:`~wx.AnyButton.GetBitmapMargins`                                           Get the margins between the bitmap and the text of the button.
:meth:`~wx.AnyButton.GetBitmapPressed`                                           Returns the bitmap for the pressed state, which may be invalid.
:meth:`~wx.AnyButton.SetBitmap`                                                  Sets the bitmap to display in the button.
:meth:`~wx.AnyButton.SetBitmapCurrent`                                           Sets the bitmap to be shown when the mouse is over the button.
:meth:`~wx.AnyButton.SetBitmapDisabled`                                          Sets the bitmap for the disabled button appearance.
:meth:`~wx.AnyButton.SetBitmapFocus`                                             Sets the bitmap for the button appearance when it has the keyboard focus.
:meth:`~wx.AnyButton.SetBitmapLabel`                                             Sets the bitmap label for the button.
:meth:`~wx.AnyButton.SetBitmapMargins`                                           Set the margins between the bitmap and the text of the button.
:meth:`~wx.AnyButton.SetBitmapPosition`                                          Set the position at which the bitmap is displayed.
:meth:`~wx.AnyButton.SetBitmapPressed`                                           Sets the bitmap for the selected (depressed) button appearance.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.AnyButton.Bitmap`                                                     See :meth:`~wx.AnyButton.GetBitmap` and :meth:`~wx.AnyButton.SetBitmap`
:attr:`~wx.AnyButton.BitmapCurrent`                                              See :meth:`~wx.AnyButton.GetBitmapCurrent` and :meth:`~wx.AnyButton.SetBitmapCurrent`
:attr:`~wx.AnyButton.BitmapDisabled`                                             See :meth:`~wx.AnyButton.GetBitmapDisabled` and :meth:`~wx.AnyButton.SetBitmapDisabled`
:attr:`~wx.AnyButton.BitmapFocus`                                                See :meth:`~wx.AnyButton.GetBitmapFocus` and :meth:`~wx.AnyButton.SetBitmapFocus`
:attr:`~wx.AnyButton.BitmapLabel`                                                See :meth:`~wx.AnyButton.GetBitmapLabel` and :meth:`~wx.AnyButton.SetBitmapLabel`
:attr:`~wx.AnyButton.BitmapMargins`                                              See :meth:`~wx.AnyButton.GetBitmapMargins` and :meth:`~wx.AnyButton.SetBitmapMargins`
:attr:`~wx.AnyButton.BitmapPressed`                                              See :meth:`~wx.AnyButton.GetBitmapPressed` and :meth:`~wx.AnyButton.SetBitmapPressed`
================================================================================ ================================================================================


|


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


.. class:: wx.AnyButton(Control)

   **Possible constructors**::

       AnyButton()
       
   
   A class for common button functionality used as the base for the
   various button classes.



   .. method:: __init__(self)






   .. method:: GetBitmap(self)

      Return the bitmap shown by the button.                  

      The returned bitmap may be invalid only if the button doesn't show any images. 

                

      :rtype: :ref:`wx.Bitmap`







      .. versionadded:: 2.9.1 
     







      .. seealso:: :meth:`SetBitmap`   








   .. method:: GetBitmapCurrent(self)

      Returns the bitmap used when the mouse is over the button, which may be invalid.                  

                

      :rtype: :ref:`wx.Bitmap`







      .. versionadded:: 2.9.1 
         (available as `BitmapButton.GetBitmapHover()` in previous versions)   







      .. seealso:: :meth:`SetBitmapCurrent`   








   .. method:: GetBitmapDisabled(self)

      Returns the bitmap for the disabled state, which may be invalid.                  

                

      :rtype: :ref:`wx.Bitmap`







      .. versionadded:: 2.9.1 
         (available in :ref:`wx.BitmapButton`  only in previous versions)   







      .. seealso:: :meth:`SetBitmapDisabled`   








   .. method:: GetBitmapFocus(self)

      Returns the bitmap for the focused state, which may be invalid.                  

                

      :rtype: :ref:`wx.Bitmap`







      .. versionadded:: 2.9.1 
         (available in :ref:`wx.BitmapButton`  only in previous versions)   







      .. seealso:: :meth:`SetBitmapFocus`   








   .. method:: GetBitmapLabel(self)

      Returns the bitmap for the normal state.                  

      This is exactly the same as :meth:`GetBitmap`   but uses a name backwards-compatible with :ref:`wx.BitmapButton`. 

                

      :rtype: :ref:`wx.Bitmap`







      .. versionadded:: 2.9.1 
         (available in :ref:`wx.BitmapButton`  only in previous versions)   







      .. seealso:: :meth:`SetBitmap` , :meth:`SetBitmapLabel`   








   .. method:: GetBitmapMargins(self)

      Get the margins between the bitmap and the text of the button.                  

                

      :rtype: :ref:`wx.Size`







      .. versionadded:: 2.9.1 
     







      .. seealso:: :meth:`SetBitmapMargins`   








   .. method:: GetBitmapPressed(self)

      Returns the bitmap for the pressed state, which may be invalid.                  

                

      :rtype: :ref:`wx.Bitmap`







      .. versionadded:: 2.9.1 
         (available as `BitmapButton.GetBitmapSelected()` in previous versions)   







      .. seealso:: :meth:`SetBitmapPressed`   








   .. method:: SetBitmap(self, bitmap, dir=LEFT)

      Sets the bitmap to display in the button.                  

      The bitmap is displayed together with the button label. This method sets up a single bitmap which is used in all button states, use :meth:`SetBitmapDisabled` , :meth:`SetBitmapPressed` , :meth:`SetBitmapCurrent`   or :meth:`SetBitmapFocus`   to change the individual images used in different states. 




      :param `bitmap`: The bitmap to display in the button. If the bitmap is invalid, any currently shown bitmaps are removed from the button.   
      :type `bitmap`: wx.Bitmap
      :param `dir`: The position of the bitmap inside the button. By default it is positioned to the left of the text, near to the left button border. Other possible values include ``wx.RIGHT``, ``wx.TOP`` and ``wx.BOTTOM``.  
      :type `dir`: wx.DataObject.Direction






                  



      .. versionadded:: 2.9.1 
     







      .. seealso:: :meth:`SetBitmapPosition` , :meth:`SetBitmapMargins`   








   .. method:: SetBitmapCurrent(self, bitmap)

      Sets the bitmap to be shown when the mouse is over the button.                  

      If `bitmap`  is invalid, the normal bitmap will be used in the current state. 

                


      :param `bitmap`: 
      :type `bitmap`: wx.Bitmap






      .. versionadded:: 2.9.1 
         (available as `BitmapButton.SetBitmapHover()` in previous versions)   







      .. seealso:: :meth:`GetBitmapCurrent`   








   .. method:: SetBitmapDisabled(self, bitmap)

      Sets the bitmap for the disabled button appearance.                  

      If `bitmap`  is invalid, the disabled bitmap is set to the automatically generated greyed out version of the normal bitmap, i.e. the same bitmap as is used by default if this method is not called at all. Use :meth:`SetBitmap`   with an invalid bitmap to remove the bitmap completely (for all states). 

                


      :param `bitmap`: 
      :type `bitmap`: wx.Bitmap






      .. versionadded:: 2.9.1 
         (available in :ref:`wx.BitmapButton`  only in previous versions)   







      .. seealso:: :meth:`GetBitmapDisabled` , :meth:`SetBitmapLabel` , :meth:`SetBitmapPressed` , :meth:`SetBitmapFocus`   








   .. method:: SetBitmapFocus(self, bitmap)

      Sets the bitmap for the button appearance when it has the keyboard focus.                  

      If `bitmap`  is invalid, the normal bitmap will be used in the focused state. 

                


      :param `bitmap`: 
      :type `bitmap`: wx.Bitmap






      .. versionadded:: 2.9.1 
         (available in :ref:`wx.BitmapButton`  only in previous versions)   







      .. seealso:: :meth:`GetBitmapFocus` , :meth:`SetBitmapLabel` , :meth:`SetBitmapPressed` , :meth:`SetBitmapDisabled`   








   .. method:: SetBitmapLabel(self, bitmap)

      Sets the bitmap label for the button.                  

                


      :param `bitmap`: 
      :type `bitmap`: wx.Bitmap






      .. versionadded:: 2.9.1 
         (available in :ref:`wx.BitmapButton`  only in previous versions)   







      .. note:: 

         This is the bitmap used for the unselected state, and for all other states if no other bitmaps are provided.  







      .. seealso:: :meth:`SetBitmap` , :meth:`GetBitmapLabel`   








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

      Set the margins between the bitmap and the text of the button.                  

      This method is currently only implemented under MSW. If it is not called, default margin is used around the bitmap. 

                 



      .. versionadded:: 2.9.1 
     







      .. seealso:: :meth:`SetBitmap` , :meth:`SetBitmapPosition`   





      |overload| Overloaded Implementations:

      **~~~**

      
      **SetBitmapMargins** `(self, x, y)`
      
      
      
      
      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int
      
      
      
      
      
      
      **~~~**

      
      **SetBitmapMargins** `(self, sz)`
      
      
      
      
      :param `sz`: 
      :type `sz`: wx.Size
      
      
      
      
      
      
      **~~~**






   .. method:: SetBitmapPosition(self, dir)

      Set the position at which the bitmap is displayed.                  

      This method should only be called if the button does have an associated bitmap. 




      :param `dir`: Direction in which the bitmap should be positioned, one of ``wx.LEFT``, ``wx.RIGHT``, ``wx.TOP`` or ``wx.BOTTOM``.   
      :type `dir`: wx.DataObject.Direction




                  



      .. versionadded:: 2.9.1 
    








   .. method:: SetBitmapPressed(self, bitmap)

      Sets the bitmap for the selected (depressed) button appearance.                  

                


      :param `bitmap`: 
      :type `bitmap`: wx.Bitmap






      .. versionadded:: 2.9.1 
         (available as `BitmapButton.SetBitmapSelected()` in previous versions)   








   .. attribute:: Bitmap

      See :meth:`~wx.AnyButton.GetBitmap` and :meth:`~wx.AnyButton.SetBitmap`


   .. attribute:: BitmapCurrent

      See :meth:`~wx.AnyButton.GetBitmapCurrent` and :meth:`~wx.AnyButton.SetBitmapCurrent`


   .. attribute:: BitmapDisabled

      See :meth:`~wx.AnyButton.GetBitmapDisabled` and :meth:`~wx.AnyButton.SetBitmapDisabled`


   .. attribute:: BitmapFocus

      See :meth:`~wx.AnyButton.GetBitmapFocus` and :meth:`~wx.AnyButton.SetBitmapFocus`


   .. attribute:: BitmapLabel

      See :meth:`~wx.AnyButton.GetBitmapLabel` and :meth:`~wx.AnyButton.SetBitmapLabel`


   .. attribute:: BitmapMargins

      See :meth:`~wx.AnyButton.GetBitmapMargins` and :meth:`~wx.AnyButton.SetBitmapMargins`


   .. attribute:: BitmapPressed

      See :meth:`~wx.AnyButton.GetBitmapPressed` and :meth:`~wx.AnyButton.SetBitmapPressed`

