********* wx.Button ********* Inheritance diagram for `wx.Button`: | .. inheritance-diagram:: wx.Button | Description =========== A button is a control that contains a text string, and is one of the most common elements of a GUI. It may be placed on a `dialog `_ or `panel `_, or indeed almost any other window. .. seealso:: `wx.BitmapButton `_ Derived From ^^^^^^^^^^^^^ * `wx.Control `_ * `wx.Window `_ * `wx.EvtHandler `_ * `wx.Object `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.BitmapButton `_, `wx.ContextHelpButton `_ Window Styles ^^^^^^^^^^^^^ ================================================== ================================================== Window Style Description ================================================== ================================================== ``wx.BU_LEFT`` Left-justifies the label. Windows and GTK+ only. ``wx.BU_TOP`` Aligns the label to the top of the button. Windows and GTK+ only. ``wx.BU_RIGHT`` Right-justifies the bitmap label. Windows and GTK+ only. ``wx.BU_BOTTOM`` Aligns the label to the bottom of the button. Windows and GTK+ only. ``wx.BU_EXACTFIT`` Creates the button as small as possible instead of making it of the standard size (which is the default behaviour). ``wx.NO_BORDER`` Creates a flat button. Windows and GTK+ only. ================================================== ================================================== Event Handling ^^^^^^^^^^^^^^ ================================================== ================================================== Event Name Description ================================================== ================================================== wx.EVT_BUTTON(id, func) Process a ``wx.wxEVT_COMMAND_BUTTON_CLICKED`` event, when the button is clicked. ================================================== ================================================== | Control Appearance ^^^^^^^^^^^^^^^^^^ | .. figure:: ../images/wxWidgets/wxmsw/button.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: ../images/wxWidgets/wxmac/button.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: ../images/wxWidgets/wxgtk/button.png :alt: wxGTK :figclass: floatcenter **wxGTK** | Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `GetDefaultSize <#GetDefaultSize>`_ * `SetDefault <#SetDefault>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(parent, id=-1, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name=wx.ButtonNameStr) Create and show a button. The preferred way to create standard buttons is to use a standard ID and an empty label. In this case wxWidgets will automatically use a stock label that corresponds to the ID given. These labels may vary across platforms as the platform itself will provide the label if possible. In addition, the button will be decorated with stock icons under GTK+ 2. **Parameters:** * `parent` (`wx.Window `_) * `id` (int) * `label` (string) * `pos` (`wx.Point `_) * `size` (`wx.Size `_) * `style` (long) * `validator` (`wx.Validator `_) * `name` (string) | **Returns:** `wx.Button `_ -------- .. method:: GetDefaultSize() Returns the default size for the buttons. It is advised to make all the dialog buttons of the same size and this function allows to retrieve the (platform and current font dependent size) which should be the best suited for this. | **Returns:** `wx.Size `_ -------- .. method:: SetDefault() This sets the button 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 `wx.Window.SetFocus `_ which sets the keyboard focus for windows and text panel items, and `wx.TopLevelWindow.SetDefaultItem `_.