SpeedMeter
tries to reproduce the behavior of some car controls (but not only),
by creating an “angular” control (actually, circular).
This is the main class implementation.
wx.lib.agw.speedmeter.BufferedWindow
Default class constructor. |
|
Converts the input values into logical x, y coordinates. |
|
Draws everything on the empty bitmap. |
|
Specify whether or not you wish to draw the external (thicker) arc. |
|
Returns the range of existence for |
|
Returns the external arc colour. |
|
Returns the direction of advancing |
|
Returns the partial filler colour. |
|
Returns the first gradient colour (near the ticks). |
|
Returns the hand (arrow indicator) colour. |
|
Returns the style for the hand (arrow indicator). |
|
Used internally. |
|
Returns the colours for the intervals. |
|
Returns the intervals for |
|
Returns the icon to be drawn near the center of |
|
Used internally. |
|
Returns the text to be drawn near the center of |
|
Returns the colour for the text in the middle. |
|
Returns the font for the text in the middle. |
|
Returns the number of secondary (intermediate) ticks. |
|
Returns the first gradient colour (near the center). |
|
Returns the hand’s shadow colour. |
|
Returns the background colour outside the |
|
Returns a list of strings and a list of integers containing the styles. |
|
Returns the current value for |
|
Returns the ticks for |
|
Returns the ticks colour. |
|
Returns the ticks font. |
|
Handles the |
|
Sets the range of existence for |
|
Sets the external arc colour (thicker line). |
|
Sets the direction of advancing |
|
Sets the partial filler colour. |
|
Sets the first gradient colour (near the ticks). |
|
Sets the hand (arrow indicator) colour. |
|
Sets the style for the hand (arrow indicator). |
|
Sets the colours for the intervals. |
|
Sets the intervals for |
|
Sets the icon to be drawn near the center of |
|
Sets the text to be drawn near the center of |
|
Sets the colour for the text in the middle. |
|
Sets the font for the text in the middle. |
|
Sets the number of secondary (intermediate) ticks. |
|
Sets the second gradient colour (near the center). |
|
Sets the hand’s shadow colour. |
|
Sets the background colour outside the |
|
Sets the current value for |
|
Sets the ticks for |
|
Sets the ticks colour. |
|
Sets the ticks font. |
SpeedMeter
(BufferedWindow)¶SpeedMeter
tries to reproduce the behavior of some car controls (but not only),
by creating an “angular” control (actually, circular).
This is the main class implementation.
__init__
(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=SM_DRAW_HAND, bufferedstyle=SM_BUFFERED_DC, mousestyle=0)¶Default class constructor.
parent – parent window. Must not be None
;
id – window identifier. A value of -1 indicates a default value;
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;
agwStyle –
this value specifies the SpeedMeter
styles, and can be a
combination of the following bits:
Window Styles |
Hex Value |
Description |
---|---|---|
|
0x1 |
Draws the ticks rotated: the ticks are rotated accordingly to the tick marks positions. |
|
0x2 |
Different intervals are painted in different colours (every sector of the circle has its own colour). |
|
0x4 |
Every interval has its own colour, but only a circle corona is painted near the ticks. |
|
0x8 |
The hand (arrow indicator) is drawn. |
|
0x10 |
A shadow for the hand is drawn. |
|
0x20 |
A circle corona that follows the hand position is drawn near the ticks. |
|
0x40 |
Intermediate (smaller) ticks are drawn between principal ticks. |
|
0x80 |
Some text is printed in the middle of the control near the center. |
|
0x100 |
An icon is drawn in the middle of the control near the center. |
|
0x200 |
A gradient of colours will fill the control. |
|
0x400 |
With this style you can use xml tags to create some custom text and draw it at the ticks position. See |
bufferedstyle –
this value allows you to use the normal PaintDC
or the
double buffered drawing options:
Buffered Styles |
Hex Value |
Description |
---|---|---|
|
0x0 |
Uses the normal |
|
0x1 |
Uses the double buffered drawing style |
mousestyle – this value allows you to use the mouse to change the SpeedMeter
value interactively with left click/drag events. If set to SM_MOUSE_TRACK
, the mouse
left click/drag allow you to change the SpeedMeter
value interactively.
CircleCoords
(self, radius, angle, centerX, centerY)¶Converts the input values into logical x, y coordinates.
radius – the SpeedMeter
radius;
angle – the angular position of the mouse;
centerX – the x position of the SpeedMeter
center;
centerX – the y position of the SpeedMeter
center.
Draw
(self, dc)¶Draws everything on the empty bitmap. Here all the chosen styles are applied.
dc – an instance of wx.DC
.
DrawExternalArc
(self, draw=True)¶Specify whether or not you wish to draw the external (thicker) arc.
draw – True
to draw the external arc, False
otherwise.
GetAngleRange
(self)¶Returns the range of existence for SpeedMeter
.
The returned values are in radians.
GetArcColour
(self)¶Returns the external arc colour.
GetDirection
(self)¶Returns the direction of advancing SpeedMeter
value.
GetFillerColour
(self)¶Returns the partial filler colour.
GetFirstGradientColour
(self)¶Returns the first gradient colour (near the ticks).
GetHandColour
(self)¶Returns the hand (arrow indicator) colour.
GetHandStyle
(self)¶Returns the style for the hand (arrow indicator).
GetIntersection
(self, current, intervals)¶Used internally.
GetIntervalColours
(self)¶Returns the colours for the intervals.
GetIntervals
(self)¶Returns the intervals for SpeedMeter
, a Python list of main ticks displayed.
GetMiddleIcon
(self)¶Returns the icon to be drawn near the center of SpeedMeter
.
GetMiddleIconDimens
(self)¶Used internally.
GetMiddleText
(self)¶Returns the text to be drawn near the center of SpeedMeter
.
GetMiddleTextColour
(self)¶Returns the colour for the text in the middle.
GetMiddleTextFont
(self)¶Returns the font for the text in the middle.
GetNumberOfSecondaryTicks
(self)¶Returns the number of secondary (intermediate) ticks.
GetSecondGradientColour
(self)¶Returns the first gradient colour (near the center).
GetShadowColour
(self)¶Returns the hand’s shadow colour.
GetSpeedBackground
(self)¶Returns the background colour outside the SpeedMeter
control.
GetSpeedStyle
(self)¶Returns a list of strings and a list of integers containing the styles.
GetSpeedValue
(self)¶Returns the current value for SpeedMeter
.
GetTicks
(self)¶Returns the ticks for SpeedMeter
intervals (main ticks string values).
GetTicksColour
(self)¶Returns the ticks colour.
GetTicksFont
(self)¶Returns the ticks font.
OnMouseMotion
(self, event)¶Handles the wx.EVT_MOUSE_EVENTS
event for SpeedMeter
.
event – a MouseEvent
event to be processed.
Note
Here only left clicks/drags are involved. Should SpeedMeter
have something more?
SetAngleRange
(self, start=0, end=pi)¶Sets the range of existence for SpeedMeter
.
start – the starting angle, in radians;
end – the ending angle, in radians.
SetArcColour
(self, colour=None)¶Sets the external arc colour (thicker line).
colour – a valid wx.Colour
object. If defaulted to None
, the arc
colour will be black.
SetDirection
(self, direction=None)¶Sets the direction of advancing SpeedMeter
value.
direction – specifying “advance” will move the hand in clock-wise direction
(like normal car speed control), while using “reverse” will move it counterclock-wise
direction. If defaulted to None
, then “advance” will be used.
SetFillerColour
(self, colour=None)¶Sets the partial filler colour.
A circle corona near the ticks will be filled with this colour, from
the starting value to the current value of SpeedMeter
.
colour – a valid wx.Colour
object.
SetFirstGradientColour
(self, colour=None)¶Sets the first gradient colour (near the ticks).
colour – a valid wx.Colour
object.
SetHandColour
(self, colour=None)¶Sets the hand (arrow indicator) colour.
colour – a valid wx.Colour
object. If defaulted to None
, the arrow
indicator will be red.
SetHandStyle
(self, style=None)¶Sets the style for the hand (arrow indicator).
style – by specifying “Hand”, SpeedMeter
will draw a polygon
that simulates the car speed control indicator. Using “Arrow” will force
SpeedMeter
to draw a simple arrow. If defaulted to None
, “Hand” will
be used.
SetIntervalColours
(self, colours=None)¶Sets the colours for the intervals.
colours – a Python list of colours. The length of this list should be
the same as the number of circle sectors in SpeedMeter
. If defaulted to None
,
all the intervals will have a white colour.
Note
Every interval (circle sector) should have a colour.
SetIntervals
(self, intervals=None)¶Sets the intervals for SpeedMeter
(main ticks numeric values).
intervals – a Python list of main ticks to be displayed. If defaulted
to None
, the list [0, 50, 100] is used.
SetMiddleIcon
(self, icon)¶Sets the icon to be drawn near the center of SpeedMeter
.
icon – a valid wx.Bitmap
object.
SetMiddleText
(self, text=None)¶Sets the text to be drawn near the center of SpeedMeter
.
text – the text to be drawn near the center of SpeedMeter
. If
defaulted to None
, an empty string will be used.
SetMiddleTextColour
(self, colour=None)¶Sets the colour for the text in the middle.
colour – a valid wx.Colour
object. If defaulted to None
, the text
in the middle will be painted in blue.
SetMiddleTextFont
(self, font=None)¶Sets the font for the text in the middle.
font – a valid wx.Font
object. If defaulted to None
, some
standard font will be generated.
SetNumberOfSecondaryTicks
(self, ticknum=None)¶Sets the number of secondary (intermediate) ticks.
ticknum – the number of intermediate ticks. If defaulted to None
,
3 ticks are used.
SetSecondGradientColour
(self, colour=None)¶Sets the second gradient colour (near the center).
colour – a valid wx.Colour
object.
SetShadowColour
(self, colour=None)¶Sets the hand’s shadow colour.
colour – a valid wx.Colour
object. If defaulted to None
, the shadow
colour will be light grey.
SetSpeedBackground
(self, colour=None)¶Sets the background colour outside the SpeedMeter
control.
colour – a valid wx.Colour
object. If defaulted to None
, the
SpeedMeter
background will be taken from the system default.
SetSpeedValue
(self, value=None)¶Sets the current value for SpeedMeter
.
value – a floating point number representing the current value. If defaulted
to None
, the SpeedMeter
value will be the middle point of the control range.
SetTicks
(self, ticks=None)¶Sets the ticks for SpeedMeter
intervals (main ticks string values).
ticks – a Python list of strings, representing the ticks values.
If defaulted to None
, the ticks will be taken from the interval values.
SetTicksColour
(self, colour=None)¶Sets the ticks colour.
colour – a valid wx.Colour
object. If defaulted to None
, the
ticks colour will be set as blue.