wx.lib.agw.shapedbutton.SButton¶
This is the main implementation of ShapedButton.
Class Hierarchy¶
Known Subclasses¶
wx.lib.agw.shapedbutton.SBitmapButton
, wx.lib.agw.shapedbutton.SToggleButton
Known Superclasses¶
Methods Summary¶
Default class constructor. |
|
Can this window be given focus by mouse click? |
|
Converts a PIL image into a |
|
Converts a |
|
Overridden base class virtual. Determines the best size of the button |
|
Draws the focus indicator. This is a circle/ellipse inside the button |
|
Draws the label on the button. |
|
Draws the main button, in whichever state it is. |
|
Enables/disables the button. |
|
Returns angle of button label rotation, in degrees. |
|
Returns the button colour. |
|
Returns the ellipse axes. |
|
Returns the button label. |
|
Returns the button label colour. |
|
Returns focus indicator flag. |
|
Calculates a new set of focus indicator colour and indicator pen |
|
Returns whether the button is enabled or not. |
|
Checks if a mouse events occurred inside the circle/ellipse or not. |
|
Creates a palette to be applied on an image based on input colour. |
|
Notifies an event and let it be processed. |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Sets angle of button label rotation. |
|
Given the current font settings, calculate and set a good size. |
|
Sets the button colour, for all button states. |
|
Sets the button as default item. |
|
Sets the ellipse axis. What it is important is not their absolute values |
|
Sets the button label. |
|
Sets the button label colour. |
|
Specifies if a focus indicator (dotted line) should be used. |
|
Overridden base class virtual. Buttons usually do not inherit |
Class API¶
- class SButton(wx.Window)¶
This is the main implementation of ShapedButton.
Methods¶
- __init__(self, parent, id=wx.ID_ANY, label='', pos=wx.DefaultPosition, size=wx.DefaultSize)¶
Default class constructor.
- Parameters:
parent – the
SButton
parent. Must not beNone
;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.
- ConvertPILToWX(self, pil, alpha=True)¶
Converts a PIL image into a
wx.Image
.- Parameters:
pil – a PIL image;
alpha –
True
if the image contains alpha transparency,False
otherwise.
- ConvertWXToPIL(self, bmp)¶
Converts a
wx.Image
into a PIL image.- Parameters:
bmp – an instance of
wx.Image
.
- DoGetBestSize(self)¶
Overridden base class virtual. Determines the best size of the button based on the label size.
Note
Overridden from
wx.Window
.
- DrawFocusIndicator(self, dc, width, height)¶
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(self, dc, width, height, dw=0, dh=0)¶
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(self, dc, width, height)¶
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(self, enable=True)¶
Enables/disables the button.
- Parameters:
enable –
True
to enable the button,False
to disable it.
Note
Overridden from
wx.Window
.
- GetAngleOfRotation(self)¶
Returns angle of button label rotation, in degrees.
- GetButtonColour(self)¶
Returns the button colour.
- GetEllipseAxis(self)¶
Returns the ellipse axes.
- GetLabel(self)¶
Returns the button label.
- GetLabelColour(self)¶
Returns the button label colour.
- GetUseFocusIndicator(self)¶
Returns focus indicator flag.
- InitColours(self)¶
Calculates a new set of focus indicator colour and indicator pen based on button colour and label colour.
- IsEnabled(self)¶
Returns whether the button is enabled or not.
- IsOutside(self, x, y)¶
Checks if a mouse events occurred inside the circle/ellipse or not.
- Parameters:
x – the mouse x position;
y – the mouse y position.
- MakePalette(self, tr, tg, tb)¶
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(self)¶
Notifies an event and let it be processed.
- OnGainFocus(self, event)¶
Handles the
wx.EVT_SET_FOCUS
event forSButton
.- Parameters:
event – a
FocusEvent
event to be processed.
- OnKeyDown(self, event)¶
Handles the
wx.EVT_KEY_DOWN
event forSButton
.- Parameters:
event – a
KeyEvent
event to be processed.
- OnKeyUp(self, event)¶
Handles the
wx.EVT_KEY_UP
event forSButton
.- Parameters:
event – a
KeyEvent
event to be processed.
- OnLeftDown(self, event)¶
Handles the
wx.EVT_LEFT_DOWN
event forSButton
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnLeftUp(self, event)¶
Handles the
wx.EVT_LEFT_UP
event forSButton
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnLoseFocus(self, event)¶
Handles the
wx.EVT_KILL_FOCUS
event forSButton
.- Parameters:
event – a
FocusEvent
event to be processed.
- OnMotion(self, event)¶
Handles the
wx.EVT_MOTION
event forSButton
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnPaint(self, event)¶
Handles the
wx.EVT_PAINT
event forSButton
.- Parameters:
event – a
PaintEvent
event to be processed.
- OnSize(self, event)¶
Handles the
wx.EVT_SIZE
event forSButton
.- Parameters:
event – a
wx.SizeEvent
event to be processed.
- SetAngleOfRotation(self, angle=None)¶
Sets angle of button label rotation.
- Parameters:
angle – the label rotation, in degrees.
- SetBestSize(self, size=None)¶
Given the current font settings, calculate and set a good size.
- Parameters:
size – if not
None
, an instance ofwx.Size
to pass toSetInitialSize
.
- SetButtonColour(self, colour=None)¶
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(self)¶
Sets the button as default item.
- SetEllipseAxis(self, main=None, secondary=None)¶
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(self, label=None)¶
Sets the button label.
- Parameters:
label – the new button label.
- SetLabelColour(self, colour=None)¶
Sets the button label colour.
- Parameters:
colour – an instance of
wx.Colour
.
- SetUseFocusIndicator(self, flag)¶
Specifies if a focus indicator (dotted line) should be used.
- Parameters:
flag –
True
to use the focus indicator,False
otherwise.
- ShouldInheritColours(self)¶
Overridden base class virtual. Buttons usually do not inherit parent’s colours.