AGW Logo

agw_title SButton

This is the main implementation of ShapedButton.

hierarchy Inheritance Diagram

Inheritance diagram for: SButton

Inheritance diagram of SButton


method_summary Methods Summary

__init__Default class constructor.
AcceptsFocusCan this window be given focus by mouse click? ..
ConvertPILToWXConverts a PIL image into a wx.Image.
ConvertWXToPILConverts a wx.Image into a PIL image.
DoGetBestSizeOverridden base class virtual.
DrawFocusIndicatorDraws the focus indicator.
DrawLabelDraws the label on the button.
DrawMainButtonDraws the main button, in whichever state it is.
EnableEnables/disables the button.
GetAngleOfRotationReturns angle of button label rotation, in degrees.
GetButtonColourReturns the button colour.
GetEllipseAxisReturns the ellipse axes.
GetLabelReturns the button label.
GetLabelColourReturns the button label colour.
GetUseFocusIndicatorReturns focus indicator flag.
InitColoursCalculates a new set of focus indicator colour and indicator pen
IsEnabledReturns wheter the button is enabled or not.
IsOutsideChecks if a mouse events occurred inside the circle/ellipse or not.
MakePaletteCreates a palette to be applied on an image based on input colour.
NotifyNotifies an event and let it be processed.
OnGainFocusHandles the wx.EVT_SET_FOCUS event for SButton.
OnKeyDownHandles the wx.EVT_KEY_DOWN event for SButton.
OnKeyUpHandles the wx.EVT_KEY_UP event for SButton.
OnLeftDownHandles the wx.EVT_LEFT_DOWN event for SButton.
OnLeftUpHandles the wx.EVT_LEFT_UP event for SButton.
OnLoseFocusHandles the wx.EVT_KILL_FOCUS event for SButton.
OnMotionHandles the wx.EVT_MOTION event for SButton.
OnPaintHandles the wx.EVT_PAINT event for SButton.
OnSizeHandles the wx.EVT_SIZE event for SButton.
SetAngleOfRotationSets angle of button label rotation.
SetBestSizeGiven the current font settings, calculate and set a good size.
SetButtonColourSets the button colour, for all button states.
SetDefaultSets the button as default item.
SetEllipseAxisSets the ellipse axis.
SetLabelSets the button label.
SetLabelColourSets the button label colour.
SetUseFocusIndicatorSpecifies if a focus indicator (dotted line) should be used.
ShouldInheritColoursOverridden base class virtual.
_GetLabelSizeUsed internally

API Class API

class SButton(wx.Window)[source]

This is the main implementation of ShapedButton.



__init__(parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize)[source]

Default class constructor.

Parameters:
  • parent – the SButton parent. Must not be None;
  • id – window identifier. A value of -1 indicates a default value;
  • label – the button text label;
  • pos – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;
  • size – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform.


AcceptsFocus()[source]

Can this window be given focus by mouse click?

Note

Overridden from wx.Window.



ConvertPILToWX(pil, alpha=True)[source]

Converts a PIL image into a wx.Image.

Parameters:
  • pil – a PIL image;
  • alphaTrue if the image contains alpha transparency, False otherwise.


ConvertWXToPIL(bmp)[source]

Converts a wx.Image into a PIL image.

Parameters:bmp – an instance of wx.Image.



DoGetBestSize()[source]

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

Note

Overridden from wx.Window.



DrawFocusIndicator(dc, width, height)[source]

Draws the focus indicator. This is a circle/ellipse inside the button drawn with a dotted-style pen, to let the user know which button has the focus.

Parameters:
  • dc – an instance of wx.DC;
  • width – the button width;
  • height – the button height.


DrawLabel(dc, width, height, dw=0, dh=0)[source]

Draws the label on the button.

Parameters:
  • dc – an instance of wx.DC;

  • width – the button width;
  • height – the button height;
  • dw – width differential, to show a 3D effect;
  • dh – height differential, to show a 3D effect.


DrawMainButton(dc, width, height)[source]

Draws the main button, in whichever state it is.

Parameters:
  • dc – an instance of wx.DC;

  • width – the button width;
  • height – the button height.


Enable(enable=True)[source]

Enables/disables the button.

Parameters:enableTrue to enable the button, False to disable it.

Note

Overridden from wx.Window.



GetAngleOfRotation()[source]

Returns angle of button label rotation, in degrees.



GetButtonColour()[source]

Returns the button colour.



GetEllipseAxis()[source]

Returns the ellipse axes.



GetLabel()[source]

Returns the button label.



GetLabelColour()[source]

Returns the button label colour.



GetUseFocusIndicator()[source]

Returns focus indicator flag.



InitColours()[source]

Calculates a new set of focus indicator colour and indicator pen based on button colour and label colour.



IsEnabled()[source]

Returns wheter the button is enabled or not.



IsOutside(x, y)[source]

Checks if a mouse events occurred inside the circle/ellipse or not.

Parameters:
  • x – the mouse x position;
  • y – the mouse y position.


MakePalette(tr, tg, tb)[source]

Creates a palette to be applied on an image based on input colour.

Parameters:
  • tr – the red intensity of the input colour;
  • tg – the green intensity of the input colour;
  • tb – the blue intensity of the input colour.


Notify()[source]

Notifies an event and let it be processed.



OnGainFocus(event)[source]

Handles the wx.EVT_SET_FOCUS event for SButton.

Parameters:event – a wx.FocusEvent event to be processed.


OnKeyDown(event)[source]

Handles the wx.EVT_KEY_DOWN event for SButton.

Parameters:event – a wx.KeyEvent event to be processed.


OnKeyUp(event)[source]

Handles the wx.EVT_KEY_UP event for SButton.

Parameters:event – a wx.KeyEvent event to be processed.



OnLeftDown(event)[source]

Handles the wx.EVT_LEFT_DOWN event for SButton.

Parameters:event – a wx.MouseEvent event to be processed.


OnLeftUp(event)[source]

Handles the wx.EVT_LEFT_UP event for SButton.

Parameters:event – a wx.MouseEvent event to be processed.



OnLoseFocus(event)[source]

Handles the wx.EVT_KILL_FOCUS event for SButton.

Parameters:event – a wx.FocusEvent event to be processed.



OnMotion(event)[source]

Handles the wx.EVT_MOTION event for SButton.

Parameters:event – a wx.MouseEvent event to be processed.



OnPaint(event)[source]

Handles the wx.EVT_PAINT event for SButton.

Parameters:event – a wx.PaintEvent event to be processed.


OnSize(event)[source]

Handles the wx.EVT_SIZE event for SButton.

Parameters:event – a wx.SizeEvent event to be processed.


SetAngleOfRotation(angle=None)[source]

Sets angle of button label rotation.

Parameters:angle – the label rotation, in degrees.


SetBestSize(size=None)[source]

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

Parameters:size – if not None, an instance of wx.Size to pass to SetInitialSize.


SetButtonColour(colour=None)[source]

Sets the button colour, for all button states.

Parameters:colour – an instance of wx.Colour.

Note

The original button images are greyscale with a lot of pixels with different colours. Changing smoothly the button colour in order to give the same 3D effect can be efficiently done only with PIL.



SetDefault()[source]

Sets the button as default item.



SetEllipseAxis(main=None, secondary=None)[source]

Sets the ellipse axis. What it is important is not their absolute values but their ratio.

Parameters:
  • main – a floating point number representing the absolute dimension of the main ellipse axis;
  • secondary – a floating point number representing the absolute dimension of the secondary ellipse axis.


SetLabel(label=None)[source]

Sets the button label.

Parameters:label – the new button label.


SetLabelColour(colour=None)[source]

Sets the button label colour.

Parameters:colour – an instance of wx.Colour.



SetUseFocusIndicator(flag)[source]

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

Parameters:flagTrue to use the focus indicator, False otherwise.


ShouldInheritColours()[source]

Overridden base class virtual. Buttons usually do not inherit parent’s colours.

Tree

Table Of Contents

Previous topic

SBitmapToggleButton

Next topic

SButtonEvent