wx.Button

Inheritance diagram for 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.

See also

wx.BitmapButton

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


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


Class API

Methods

__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:


Returns:

wx.Button


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


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.