.. 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

.. currentmodule:: wx.lib.buttons

.. highlight:: python



.. _wx.lib.buttons.GenButton:

==========================================================================================================================================
|phoenix_title|  **wx.lib.buttons.GenButton**
==========================================================================================================================================

A generic button, and base class for the other generic buttons. 



|

|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>GenButton</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.lib.buttons.GenButton_inheritance.png" alt="Inheritance diagram of GenButton" 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.Trackable.html" title="wx.Trackable" alt="" coords="5,5,107,35"/> <area shape="rect" id="node2" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="57,83,168,112"/> <area shape="rect" id="node6" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="53,160,173,189"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="131,5,212,35"/> <area shape="rect" id="node4" href="wx.Control.html" title="wx.Control" alt="" coords="69,315,157,344"/> <area shape="rect" id="node7" href="wx.lib.buttons.GenButton.html" title="wx.lib.buttons.GenButton" alt="" coords="22,392,204,421"/> <area shape="rect" id="node5" href="wx.Window.html" title="wx.Window" alt="" coords="69,237,157,267"/> </map> 
   </p>

|


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

:class:`wx.lib.analogclock.lib_setup.fontselect.FontSelect`, :class:`wx.lib.buttons.GenBitmapButton`, :class:`wx.lib.buttons.GenToggleButton`, :class:`wx.lib.buttons.ThemedGenButton`

|


|super_classes| Known Superclasses
==================================

:class:`wx.Control`

|


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

================================================================================ ================================================================================
:meth:`~wx.lib.buttons.GenButton.__init__`                                       Default class constructor.
:meth:`~wx.lib.buttons.GenButton.AcceptsFocus`                                   Can this window be given focus by mouse click?
:meth:`~wx.lib.buttons.GenButton.DoGetBestSize`                                  Overridden base class virtual. Determines the best size of the
:meth:`~wx.lib.buttons.GenButton.DrawBezel`                                      
:meth:`~wx.lib.buttons.GenButton.DrawFocusIndicator`                             
:meth:`~wx.lib.buttons.GenButton.DrawLabel`                                      
:meth:`~wx.lib.buttons.GenButton.Enable`                                         Enables/disables the button.
:meth:`~wx.lib.buttons.GenButton.GetBackgroundBrush`                             Returns the current :class:`wx.Brush` to be used to draw the button background.
:meth:`~wx.lib.buttons.GenButton.GetBezelWidth`                                  Returns the width of the 3D effect, in pixels.
:meth:`~wx.lib.buttons.GenButton.GetDefaultAttributes`                           Overridden base class virtual. By default we should use
:meth:`~wx.lib.buttons.GenButton.GetUseFocusIndicator`                           Returns the focus indicator flag, specifying if a focus indicator
:meth:`~wx.lib.buttons.GenButton.InitColours`                                    Calculate a new set of highlight and shadow colours based on
:meth:`~wx.lib.buttons.GenButton.InitOtherEvents`                                Override this method in a subclass to initialize any other events that
:meth:`~wx.lib.buttons.GenButton.Notify`                                         Actually sends a ``wx.EVT_BUTTON`` event to the listener (if any).
:meth:`~wx.lib.buttons.GenButton.OnGainFocus`                                    Handles the ``wx.EVT_SET_FOCUS`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnKeyDown`                                      Handles the ``wx.EVT_KEY_DOWN`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnKeyUp`                                        Handles the ``wx.EVT_KEY_UP`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnLeftDown`                                     Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnLeftUp`                                       Handles the ``wx.EVT_LEFT_UP`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnLoseFocus`                                    Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnMotion`                                       Handles the ``wx.EVT_MOTION`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnPaint`                                        Handles the ``wx.EVT_PAINT`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.OnSize`                                         Handles the ``wx.EVT_SIZE`` event for :class:`GenButton`.
:meth:`~wx.lib.buttons.GenButton.SetBackgroundColour`                            Sets the :class:`GenButton` background colour.
:meth:`~wx.lib.buttons.GenButton.SetBezelWidth`                                  Sets the width of the 3D effect.
:meth:`~wx.lib.buttons.GenButton.SetDefault`                                     This sets the :class:`GenButton` to be the default item for
:meth:`~wx.lib.buttons.GenButton.SetForegroundColour`                            Sets the :class:`wx.GenButton` foreground colour.
:meth:`~wx.lib.buttons.GenButton.SetInitialSize`                                 Given the current font and bezel width settings, calculate
:meth:`~wx.lib.buttons.GenButton.SetUseFocusIndicator`                           Specifies if a focus indicator (dotted line) should be used.
:meth:`~wx.lib.buttons.GenButton.ShouldInheritColours`                           Overridden base class virtual. Buttons usually don't inherit
================================================================================ ================================================================================


|


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


.. class:: GenButton(wx.Control)

   A generic button, and base class for the other generic buttons. 

   .. method:: __init__(self, parent, id=-1, label='', pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, validator = wx.DefaultValidator, name = "genbutton")

      Default class constructor.
      
      :param wx.Window `parent`: parent window. Must not be ``None``;
      :param integer `id`: window identifier. A value of -1 indicates a default value;
      :param string `label`: the button text label;
      :param `pos`: the control position. A value of (-1, -1) indicates a default
       position, chosen by either the windowing system or wxPython, depending on
       platform;
      :type `pos`: tuple or :class:`wx.Point`
      :param `size`: the control size. A value of (-1, -1) indicates a default size,
       chosen by either the windowing system or wxPython, depending on platform;
      :type `size`: tuple or :class:`wx.Size`
      :param integer `style`: the button style;
      :param wx.Validator `validator`: the validator associated with the button;
      :param string `name`: the button name.
      
      .. seealso:: :class:`wx.Button` for a list of valid window styles.


   .. method:: AcceptsFocus(self)

      Can this window be given focus by mouse click?
      
      .. note:: Overridden from :class:`wx.Control`.


   .. method:: DoGetBestSize(self)

      Overridden base class virtual. Determines the best size of the
      button based on the label and bezel size.
      
      :return: An instance of :class:`wx.Size`.
      
      .. note:: Overridden from :class:`wx.Control`.


   .. method:: DrawBezel(self, dc, x1, y1, x2, y2)


   .. method:: DrawFocusIndicator(self, dc, w, h)


   .. method:: DrawLabel(self, dc, width, height, dx=0, dy=0)


   .. method:: Enable(self, enable=True)

      Enables/disables the button.
      
      :param bool `enable`: ``True`` to enable the button, ``False`` to disable it.
      
      .. note:: Overridden from :class:`wx.Control`.


   .. method:: GetBackgroundBrush(self, dc)

      Returns the current :class:`wx.Brush` to be used to draw the button background.
      
      :param wx.DC `dc`: the device context used to draw the button background.


   .. method:: GetBezelWidth(self)

      Returns the width of the 3D effect, in pixels.
      
      :rtype: integer


   .. method:: GetDefaultAttributes(self)

      Overridden base class virtual. By default we should use
      the same font/colour attributes as the native :class:`wx.Button`.
      
      :return: an instance of :class:`wx.VisualAttributes`.
      
      .. note:: Overridden from :class:`wx.Control`.


   .. method:: GetUseFocusIndicator(self)

      Returns the focus indicator flag, specifying if a focus indicator
      (dotted line) is being used.
      
      :rtype: bool


   .. method:: InitColours(self)

      Calculate a new set of highlight and shadow colours based on
      the background colour. Works okay if the colour is dark...


   .. method:: InitOtherEvents(self)

      Override this method in a subclass to initialize any other events that
      need to be bound.  Added so :meth:`__init__` doesn't need to be
      overriden, which is complicated with multiple inheritance.


   .. method:: Notify(self)

      Actually sends a ``wx.EVT_BUTTON`` event to the listener (if any). 


   .. method:: OnGainFocus(self, event)

      Handles the ``wx.EVT_SET_FOCUS`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.FocusEvent` event to be processed.


   .. method:: OnKeyDown(self, event)

      Handles the ``wx.EVT_KEY_DOWN`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.KeyEvent` event to be processed.


   .. method:: OnKeyUp(self, event)

      Handles the ``wx.EVT_KEY_UP`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.KeyEvent` event to be processed.


   .. method:: OnLeftDown(self, event)

      Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.MouseEvent` event to be processed.


   .. method:: OnLeftUp(self, event)

      Handles the ``wx.EVT_LEFT_UP`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.MouseEvent` event to be processed.


   .. method:: OnLoseFocus(self, event)

      Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.FocusEvent` event to be processed.


   .. method:: OnMotion(self, event)

      Handles the ``wx.EVT_MOTION`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.MouseEvent` event to be processed.


   .. method:: OnPaint(self, event)

      Handles the ``wx.EVT_PAINT`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.PaintEvent` event to be processed.


   .. method:: OnSize(self, event)

      Handles the ``wx.EVT_SIZE`` event for :class:`GenButton`.
      
      :param `event`: a :class:`wx.SizeEvent` event to be processed.


   .. method:: SetBackgroundColour(self, colour)

      Sets the :class:`GenButton` background colour.
      
      :param `colour`: a valid :class:`wx.Colour` object.
      
      .. note:: Overridden from :class:`wx.Control`.


   .. method:: SetBezelWidth(self, width)

      Sets the width of the 3D effect.
      
      :param integer `width`: the 3D border width, in pixels.


   .. method:: SetDefault(self)

      This sets the :class:`GenButton` to be the default item for
      the panel or dialog box.
      
      .. note:: Under Windows, only dialog box buttons respond to this function.
         As normal under Windows and Motif, pressing return causes the
         default button to be depressed when the return key is pressed. See
         also :meth:`wx.Window.SetFocus` which sets the keyboard focus for
         windows and text panel items, and
         :meth:`wx.TopLevelWindow.SetDefaultItem`.
      
      .. note:: Note that under Motif, calling this function immediately after
         creation of a button and before the creation of other buttons will
         cause misalignment of the row of buttons, since default buttons are
         larger. To get around this, call :meth:`wx.SetDefault` after you
         have created a row of buttons: wxPython will then set the size of
         all buttons currently on the panel to the same size.


   .. method:: SetForegroundColour(self, colour)

      Sets the :class:`wx.GenButton` foreground colour.
      
      :param `colour`: a valid :class:`wx.Colour` object.
      
      .. note:: Overridden from :class:`wx.Control`.


   .. method:: SetInitialSize(self, size=None)

      Given the current font and bezel width settings, calculate
      and set a good size.
      
      :param `size`: an instance of :class:`wx.Size` or ``None``,
       in which case the wxPython
       ``wx.DefaultSize`` is used instead.


   .. method:: SetUseFocusIndicator(self, flag)

      Specifies if a focus indicator (dotted line) should be used.
      
      :param bool `flag`: ``True`` to draw a focus ring, ``False`` otherwise.


   .. method:: ShouldInheritColours(self)

      Overridden base class virtual. Buttons usually don't inherit
      the parent's colours.
      
      .. note:: Overridden from :class:`wx.Control`.


