This is the main implementation of ShapedButton.
wx.lib.agw.shapedbutton.SBitmapButton
, wx.lib.agw.shapedbutton.SToggleButton
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 |
SButton
(wx.Window)¶This is the main implementation of ShapedButton.
__init__
(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize)¶Default class constructor.
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.
ConvertPILToWX
(self, pil, alpha=True)¶Converts a PIL image into a wx.Image
.
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.
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.
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.
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.
dc – an instance of wx.DC
;
width – the button width;
height – the button height.
Enable
(self, enable=True)¶Enables/disables the button.
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.
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.
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 for SButton
.
event – a FocusEvent
event to be processed.
OnKeyDown
(self, event)¶Handles the wx.EVT_KEY_DOWN
event for SButton
.
event – a KeyEvent
event to be processed.
OnKeyUp
(self, event)¶Handles the wx.EVT_KEY_UP
event for SButton
.
event – a KeyEvent
event to be processed.
OnLeftDown
(self, event)¶Handles the wx.EVT_LEFT_DOWN
event for SButton
.
event – a MouseEvent
event to be processed.
OnLeftUp
(self, event)¶Handles the wx.EVT_LEFT_UP
event for SButton
.
event – a MouseEvent
event to be processed.
OnLoseFocus
(self, event)¶Handles the wx.EVT_KILL_FOCUS
event for SButton
.
event – a FocusEvent
event to be processed.
OnMotion
(self, event)¶Handles the wx.EVT_MOTION
event for SButton
.
event – a MouseEvent
event to be processed.
OnPaint
(self, event)¶Handles the wx.EVT_PAINT
event for SButton
.
event – a PaintEvent
event to be processed.
OnSize
(self, event)¶Handles the wx.EVT_SIZE
event for SButton
.
event – a wx.SizeEvent
event to be processed.
SetAngleOfRotation
(self, angle=None)¶Sets angle of button label rotation.
angle – the label rotation, in degrees.
SetBestSize
(self, size=None)¶Given the current font settings, calculate and set a good size.
size – if not None
, an instance of wx.Size
to pass to
SetInitialSize
.
SetButtonColour
(self, colour=None)¶Sets the button colour, for all button states.
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.
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.
label – the new button label.
SetLabelColour
(self, colour=None)¶Sets the button label colour.
colour – an instance of wx.Colour
.
SetUseFocusIndicator
(self, flag)¶Specifies if a focus indicator (dotted line) should be used.
flag – True
to use the focus indicator, False
otherwise.
ShouldInheritColours
(self)¶Overridden base class virtual. Buttons usually do not inherit parent’s colours.