wx.lib.buttons.GenButton¶A generic button, and base class for the other generic buttons.
Class Hierarchy¶
Inheritance diagram for class GenButton:

Known Subclasses¶wx.lib.analogclock.lib_setup.fontselect.FontSelect, wx.lib.buttons.GenBitmapButton, wx.lib.buttons.GenToggleButton, wx.lib.buttons.ThemedGenButton
Known Superclasses¶
Methods Summary¶Default class constructor. |
|
Can this window be given focus by mouse click? |
|
Overridden base class virtual. Determines the best size of the |
|
Enables/disables the button. |
|
Returns the current |
|
Returns the width of the 3D effect, in pixels. |
|
Overridden base class virtual. By default we should use |
|
Returns the focus indicator flag, specifying if a focus indicator |
|
Calculate a new set of highlight and shadow colours based on |
|
Override this method in a subclass to initialize any other events that |
|
Actually sends a |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Sets the |
|
Sets the width of the 3D effect. |
|
This sets the |
|
Sets the |
|
Given the current font and bezel width settings, calculate |
|
Specifies if a focus indicator (dotted line) should be used. |
|
Overridden base class virtual. Buttons usually don’t inherit |
Class API¶GenButton(wx.Control)¶A generic button, and base class for the other generic buttons.
__init__(self, parent, id=-1, label='', pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, validator = wx.DefaultValidator, name = "genbutton")¶Default class constructor.
parent (wx.Window) – parent window. Must not be None;
id (integer) – window identifier. A value of -1 indicates a default value;
label (string) – the button text label;
pos (tuple or wx.Point) – the control position. A value of (-1, -1) indicates a default
position, chosen by either the windowing system or wxPython, depending on
platform;
size (tuple or wx.Size) – the control size. A value of (-1, -1) indicates a default size,
chosen by either the windowing system or wxPython, depending on platform;
style (integer) – the button style;
validator (wx.Validator) – the validator associated with the button;
name (string) – the button name.
See also
wx.Button for a list of valid window styles.
AcceptsFocus(self)¶Can this window be given focus by mouse click?
Note
Overridden from wx.Control.
DoGetBestSize(self)¶Overridden base class virtual. Determines the best size of the button based on the label and bezel size.
An instance of wx.Size.
Note
Overridden from wx.Control.
DrawBezel(self, dc, x1, y1, x2, y2)¶DrawFocusIndicator(self, dc, w, h)¶DrawLabel(self, dc, width, height, dx=0, dy=0)¶Enable(self, enable=True)¶Enables/disables the button.
enable (bool) – True to enable the button, False to disable it.
Note
Overridden from wx.Control.
GetBackgroundBrush(self, dc)¶Returns the current wx.Brush to be used to draw the button background.
dc (wx.DC) – the device context used to draw the button background.
GetBezelWidth(self)¶Returns the width of the 3D effect, in pixels.
integer
GetDefaultAttributes(self)¶Overridden base class virtual. By default we should use
the same font/colour attributes as the native wx.Button.
an instance of wx.VisualAttributes.
Note
Overridden from wx.Control.
GetUseFocusIndicator(self)¶Returns the focus indicator flag, specifying if a focus indicator (dotted line) is being used.
bool
InitColours(self)¶Calculate a new set of highlight and shadow colours based on the background colour. Works okay if the colour is dark…
InitOtherEvents(self)¶Override this method in a subclass to initialize any other events that
need to be bound. Added so __init__ doesn’t need to be
overridden, which is complicated with multiple inheritance.
Notify(self)¶Actually sends a wx.EVT_BUTTON event to the listener (if any).
OnGainFocus(self, event)¶Handles the wx.EVT_SET_FOCUS event for GenButton.
event – a wx.FocusEvent event to be processed.
OnKeyDown(self, event)¶Handles the wx.EVT_KEY_DOWN event for GenButton.
event – a wx.KeyEvent event to be processed.
OnKeyUp(self, event)¶Handles the wx.EVT_KEY_UP event for GenButton.
event – a wx.KeyEvent event to be processed.
OnLeftDown(self, event)¶Handles the wx.EVT_LEFT_DOWN event for GenButton.
event – a wx.MouseEvent event to be processed.
OnLeftUp(self, event)¶Handles the wx.EVT_LEFT_UP event for GenButton.
event – a wx.MouseEvent event to be processed.
OnLoseCapture(self, event)¶Handles the wx.EVT_MOUSE_CAPTURE_LOST event for GenButton.
event – a wx.MouseCaptureLostEvent event to be processed.
OnLoseFocus(self, event)¶Handles the wx.EVT_KILL_FOCUS event for GenButton.
event – a wx.FocusEvent event to be processed.
OnMotion(self, event)¶Handles the wx.EVT_MOTION event for GenButton.
event – a wx.MouseEvent event to be processed.
OnPaint(self, event)¶Handles the wx.EVT_PAINT event for GenButton.
event – a wx.PaintEvent event to be processed.
OnSize(self, event)¶Handles the wx.EVT_SIZE event for GenButton.
event – a wx.SizeEvent event to be processed.
SetBackgroundColour(self, colour)¶Sets the GenButton background colour.
colour – a valid wx.Colour object.
Note
Overridden from wx.Control.
SetBezelWidth(self, width)¶Sets the width of the 3D effect.
width (integer) – the 3D border width, in pixels.
SetDefault(self)¶This sets the 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 wx.Window.SetFocus which sets the keyboard focus for
windows and text panel items, and
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 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.
SetForegroundColour(self, colour)¶Sets the wx.GenButton foreground colour.
colour – a valid wx.Colour object.
Note
Overridden from wx.Control.
SetInitialSize(self, size=None)¶Given the current font and bezel width settings, calculate and set a good size.
size – an instance of wx.Size or None,
in which case the wxPython
wx.DefaultSize is used instead.
SetUseFocusIndicator(self, flag)¶Specifies if a focus indicator (dotted line) should be used.
flag (bool) – True to draw a focus ring, False otherwise.
ShouldInheritColours(self)¶Overridden base class virtual. Buttons usually don’t inherit the parent’s colours.
Note
Overridden from wx.Control.