phoenix_title wx.lib.buttons.GenButton

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


class_hierarchy Class Hierarchy

Inheritance diagram for class GenButton:

super_classes Known Superclasses

wx.Control


method_summary Methods Summary

__init__

Default class constructor.

AcceptsFocus

Can this window be given focus by mouse click?

DoGetBestSize

Overridden base class virtual. Determines the best size of the

DrawBezel

DrawFocusIndicator

DrawLabel

Enable

Enables/disables the button.

GetBackgroundBrush

Returns the current wx.Brush to be used to draw the button background.

GetBezelWidth

Returns the width of the 3D effect, in pixels.

GetDefaultAttributes

Overridden base class virtual. By default we should use

GetUseFocusIndicator

Returns the focus indicator flag, specifying if a focus indicator

InitColours

Calculate a new set of highlight and shadow colours based on

InitOtherEvents

Override this method in a subclass to initialize any other events that

Notify

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

OnGainFocus

Handles the wx.EVT_SET_FOCUS event for GenButton.

OnKeyDown

Handles the wx.EVT_KEY_DOWN event for GenButton.

OnKeyUp

Handles the wx.EVT_KEY_UP event for GenButton.

OnLeftDown

Handles the wx.EVT_LEFT_DOWN event for GenButton.

OnLeftUp

Handles the wx.EVT_LEFT_UP event for GenButton.

OnLoseCapture

Handles the wx.EVT_MOUSE_CAPTURE_LOST event for GenButton.

OnLoseFocus

Handles the wx.EVT_KILL_FOCUS event for GenButton.

OnMotion

Handles the wx.EVT_MOTION event for GenButton.

OnPaint

Handles the wx.EVT_PAINT event for GenButton.

OnSize

Handles the wx.EVT_SIZE event for GenButton.

SetBackgroundColour

Sets the GenButton background colour.

SetBezelWidth

Sets the width of the 3D effect.

SetDefault

This sets the GenButton to be the default item for

SetForegroundColour

Sets the wx.GenButton foreground colour.

SetInitialSize

Given the current font and bezel width settings, calculate

SetUseFocusIndicator

Specifies if a focus indicator (dotted line) should be used.

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.


Methods

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

Default class constructor.

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

Returns

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.

Parameters

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.

Parameters

dc (wx.DC) – the device context used to draw the button background.



GetBezelWidth(self)

Returns the width of the 3D effect, in pixels.

Return type

integer



GetDefaultAttributes(self)

Overridden base class virtual. By default we should use the same font/colour attributes as the native wx.Button.

Returns

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.

Return type

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.

Parameters

event – a wx.FocusEvent event to be processed.



OnKeyDown(self, event)

Handles the wx.EVT_KEY_DOWN event for GenButton.

Parameters

event – a wx.KeyEvent event to be processed.



OnKeyUp(self, event)

Handles the wx.EVT_KEY_UP event for GenButton.

Parameters

event – a wx.KeyEvent event to be processed.



OnLeftDown(self, event)

Handles the wx.EVT_LEFT_DOWN event for GenButton.

Parameters

event – a wx.MouseEvent event to be processed.



OnLeftUp(self, event)

Handles the wx.EVT_LEFT_UP event for GenButton.

Parameters

event – a wx.MouseEvent event to be processed.



OnLoseCapture(self, event)

Handles the wx.EVT_MOUSE_CAPTURE_LOST event for GenButton.

Parameters

event – a wx.MouseCaptureLostEvent event to be processed.



OnLoseFocus(self, event)

Handles the wx.EVT_KILL_FOCUS event for GenButton.

Parameters

event – a wx.FocusEvent event to be processed.



OnMotion(self, event)

Handles the wx.EVT_MOTION event for GenButton.

Parameters

event – a wx.MouseEvent event to be processed.



OnPaint(self, event)

Handles the wx.EVT_PAINT event for GenButton.

Parameters

event – a wx.PaintEvent event to be processed.



OnSize(self, event)

Handles the wx.EVT_SIZE event for GenButton.

Parameters

event – a wx.SizeEvent event to be processed.



SetBackgroundColour(self, colour)

Sets the GenButton background colour.

Parameters

colour – a valid wx.Colour object.

Note

Overridden from wx.Control.



SetBezelWidth(self, width)

Sets the width of the 3D effect.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

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.