Table Of Contents

Previous topic

__ToggleMixin

Next topic

AquaButtonEvent

This Page

phoenix_title AquaButton

This is the main class implementation of AquaButton.


class_hierarchy Inheritance Diagram

Inheritance diagram for class AquaButton

Inheritance diagram of AquaButton


appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


super_classes Known Superclasses

PyControl


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
Enable Enables/disables the button.
GetBackgroundColour Returns the button colour when the mouse is not hovering on the button.
GetDefaultAttributes Overridden base class virtual. By default we should use
GetDisabledColour Returns the button colour when it is disabled.
GetForegroundColour Returns the text colour for AquaButton.
GetHoverColour Returns the button colour when the mouse is hovering on the button.
GetPath Returns a rounded GraphicsPath rectangle.
GetPulseOnFocus Returns whether the pulsing effect is active.
Invalidate Invalidate the saved bitmap and refresh the button.
LightColour Return light contrast of colour. The colour returned is from the scale of
Notify Actually sends a EVT_BUTTON event to the listener (if any).
OnGainFocus Handles the EVT_SET_FOCUS event for AquaButton.
OnKeyDown Handles the EVT_KEY_DOWN event for AquaButton.
OnKeyUp Handles the EVT_KEY_UP event for AquaButton.
OnLeftDown Handles the EVT_LEFT_DOWN event for AquaButton.
OnLeftUp Handles the EVT_LEFT_UP event for AquaButton.
OnLoseFocus Handles the EVT_KILL_FOCUS event for AquaButton.
OnMouseEnter Handles the EVT_ENTER_WINDOW event for AquaButton.
OnMouseLeave Handles the EVT_LEAVE_WINDOW event for AquaButton.
OnPaint Handles the EVT_PAINT event for AquaButton.
OnPulseTimer Handles the EVT_TIMER event for AquaButton.
OnSize Handles the EVT_SIZE event for AquaButton.
SetBackgroundColour Sets the AquaButton background colour.
SetBitmapLabel Sets the bitmap label for the button.
SetDefault This sets the AquaButton to be the default item for the panel or dialog box.
SetDisabledColour Sets the button colour when it is disabled.
SetForegroundColour Sets the AquaButton foreground (text) colour.
SetHoverColour Sets the button colour when the mouse is hovering on the button.
SetInitialSize Given the current font and bezel width settings, calculate
SetPulseOnFocus Sets whether to enable the pulsing effect on gaining focus or not.
ShouldInheritColours Overridden base class virtual. Buttons usually don’t inherit

api Class API



class AquaButton(PyControl)

This is the main class implementation of AquaButton.


Methods



__init__(self, parent, id=ID_ANY, bitmap=None, label="", pos=DefaultPosition, size=DefaultSize, style=NO_BORDER, validator=DefaultValidator, name="aquabutton")

Default class constructor.

Parameters:
  • parent (Window) – parent window. Must not be None;
  • id (integer) – window identifier. A value of -1 indicates a default value;
  • bitmap (Bitmap) – the button bitmap (if any);
  • label (string) – the button text label;
  • pos (tuple or 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 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 (unused);
  • validator (Validator) – the validator associated to the button;
  • name (string) – the button name.


AcceptsFocus(self)

Can this window be given focus by mouse click?

Note

Overridden from PyControl.



DoGetBestSize(self)

Overridden base class virtual. Determines the best size of the button based on the label and bezel size.

Returns:An instance of Size.

Note

Overridden from PyControl.



Enable(self, enable=True)

Enables/disables the button.

Parameters:enable (bool) – True to enable the button, False to disable it.

Note

Overridden from PyControl.



GetBackgroundColour(self)

Returns the button colour when the mouse is not hovering on the button.

Returns:An instance of Colour.

Note

Overridden from PyControl.



GetDefaultAttributes(self)

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

Returns:an instance of VisualAttributes.

Note

Overridden from PyControl.



GetDisabledColour(self)

Returns the button colour when it is disabled.

Returns:An instance of Colour.


GetForegroundColour(self)

Returns the text colour for AquaButton.

Returns:An instance of Colour.

Note

Overridden from PyControl.



GetHoverColour(self)

Returns the button colour when the mouse is hovering on the button.

Returns:An instance of Colour.


GetPath(self, gc, rc, r)

Returns a rounded GraphicsPath rectangle.

Parameters:
  • gc – an instance of GraphicsContext;
  • rc (Rect) – a client rectangle;
  • r (float) – the radius of the rounded part of the rectangle.
Returns:

A rounded rectangle, an instance of GraphicsPath.



GetPulseOnFocus(self)

Returns whether the pulsing effect is active.

Returns:True if the pulsing effect is active, False otherwise.


Invalidate(self)

Invalidate the saved bitmap and refresh the button.



LightColour(self, colour, percent)

Return light contrast of colour. The colour returned is from the scale of colour ==> white.

Parameters:
  • colour – the input colour to be brightened, a valid instance of Colour;
  • percent (integer) – determines how light the colour will be. percent = 100 returns white, percent = 0 returns colour.
Returns:

A light contrast of the input colour, an instance of Colour.



Notify(self)

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



OnGainFocus(self, event)

Handles the EVT_SET_FOCUS event for AquaButton.

Parameters:event – a FocusEvent event to be processed.


OnKeyDown(self, event)

Handles the EVT_KEY_DOWN event for AquaButton.

Parameters:event – a KeyEvent event to be processed.


OnKeyUp(self, event)

Handles the EVT_KEY_UP event for AquaButton.

Parameters:event – a KeyEvent event to be processed.


OnLeftDown(self, event)

Handles the EVT_LEFT_DOWN event for AquaButton.

Parameters:event – a MouseEvent event to be processed.


OnLeftUp(self, event)

Handles the EVT_LEFT_UP event for AquaButton.

Parameters:event – a MouseEvent event to be processed.


OnLoseFocus(self, event)

Handles the EVT_KILL_FOCUS event for AquaButton.

Parameters:event – a FocusEvent event to be processed.


OnMouseEnter(self, event)

Handles the EVT_ENTER_WINDOW event for AquaButton.

Parameters:event – a MouseEvent event to be processed.


OnMouseLeave(self, event)

Handles the EVT_LEAVE_WINDOW event for AquaButton.

Parameters:event – a MouseEvent event to be processed.


OnPaint(self, event)

Handles the EVT_PAINT event for AquaButton.

Parameters:event – a PaintEvent event to be processed.


OnPulseTimer(self, event)

Handles the EVT_TIMER event for AquaButton.

Parameters:event – a TimerEvent event to be processed.

Note

This method is only invoked when pulseOnFocus is True.



OnSize(self, event)

Handles the EVT_SIZE event for AquaButton.

Parameters:event – a SizeEvent event to be processed.


SetBackgroundColour(self, colour)

Sets the AquaButton background colour.

Parameters:colour – a valid Colour object.

Note

Overridden from PyControl.



SetBitmapLabel(self, bitmap)

Sets the bitmap label for the button.

Parameters:bitmap – the bitmap label to set, an instance of Bitmap.


SetDefault(self)

This sets the AquaButton 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 Window.SetFocus which sets the keyboard focus for windows and text panel items, and 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 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.



SetDisabledColour(self, colour)

Sets the button colour when it is disabled.

Parameters:colour – a valid Colour object.


SetForegroundColour(self, colour)

Sets the AquaButton foreground (text) colour.

Parameters:colour – a valid Colour object.

Note

Overridden from PyControl.



SetHoverColour(self, colour)

Sets the button colour when the mouse is hovering on the button.

Parameters:colour – a valid Colour object.


SetInitialSize(self, size=None)

Given the current font and bezel width settings, calculate and set a good size.

Parameters:size – an instance of Size or None, in which case the wxWidgets DefaultSize is used instead.


SetPulseOnFocus(self, pulse)

Sets whether to enable the pulsing effect on gaining focus or not.

Parameters:pulse (bool) – True to enable pulsing when the AquaButton gains focus, False to disable this effect.


ShouldInheritColours(self)

Overridden base class virtual. Buttons usually don’t inherit the parent’s colours.

Note

Overridden from PyControl.