wx.lib.agw.speedmeter.SpeedMeter¶
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.
Class Hierarchy¶
Control Appearance¶
Known Superclasses¶
wx.lib.agw.speedmeter.BufferedWindow
Methods Summary¶
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. |
Class API¶
- class SpeedMeter(BufferedWindow)¶
SpeedMetertries to reproduce the behavior of some car controls (but not only), by creating an “angular” control (actually, circular).This is the main class implementation.
Methods¶
- __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.
- Parameters:
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
SpeedMeterstyles, and can be a combination of the following bits:Window Styles
Hex Value
Description
SM_ROTATE_TEXT0x1
Draws the ticks rotated: the ticks are rotated accordingly to the tick marks positions.
SM_DRAW_SECTORS0x2
Different intervals are painted in different colours (every sector of the circle has its own colour).
SM_DRAW_PARTIAL_SECTORS0x4
Every interval has its own colour, but only a circle corona is painted near the ticks.
SM_DRAW_HAND0x8
The hand (arrow indicator) is drawn.
SM_DRAW_SHADOW0x10
A shadow for the hand is drawn.
SM_DRAW_PARTIAL_FILLER0x20
A circle corona that follows the hand position is drawn near the ticks.
SM_DRAW_SECONDARY_TICKS0x40
Intermediate (smaller) ticks are drawn between principal ticks.
SM_DRAW_MIDDLE_TEXT0x80
Some text is printed in the middle of the control near the center.
SM_DRAW_MIDDLE_ICON0x100
An icon is drawn in the middle of the control near the center.
SM_DRAW_GRADIENT0x200
A gradient of colours will fill the control.
SM_DRAW_FANCY_TICKS0x400
With this style you can use xml tags to create some custom text and draw it at the ticks position. See
lib.fancytextfor the tags.bufferedstyle –
this value allows you to use the normal
PaintDCor the double buffered drawing options:Buffered Styles
Hex Value
Description
SM_NORMAL_DC0x0
Uses the normal
PaintDCSM_BUFFERED_DC0x1
Uses the double buffered drawing style
mousestyle – this value allows you to use the mouse to change the
SpeedMetervalue interactively with left click/drag events. If set toSM_MOUSE_TRACK, the mouse left click/drag allow you to change theSpeedMetervalue interactively.
- CircleCoords(self, radius, angle, centerX, centerY)¶
Converts the input values into logical x, y coordinates.
- Parameters:
radius – the
SpeedMeterradius;angle – the angular position of the mouse;
centerX – the x position of the
SpeedMetercenter;centerX – the y position of the
SpeedMetercenter.
- Draw(self, dc)¶
Draws everything on the empty bitmap. Here all the chosen styles are applied.
- Parameters:
dc – an instance of
wx.DC.
- DrawExternalArc(self, draw=True)¶
Specify whether or not you wish to draw the external (thicker) arc.
- Parameters:
draw –
Trueto draw the external arc,Falseotherwise.
- 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
SpeedMetervalue.
- 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
SpeedMetercontrol.
- 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
SpeedMeterintervals (main ticks string values).
- GetTicksColour(self)¶
Returns the ticks colour.
- GetTicksFont(self)¶
Returns the ticks font.
- OnMouseMotion(self, event)¶
Handles the
wx.EVT_MOUSE_EVENTSevent forSpeedMeter.- Parameters:
event – a
MouseEventevent to be processed.
Note
Here only left clicks/drags are involved. Should
SpeedMeterhave something more?
- SetAngleRange(self, start=0, end=pi)¶
Sets the range of existence for
SpeedMeter.- Parameters:
start – the starting angle, in radians;
end – the ending angle, in radians.
- SetArcColour(self, colour=None)¶
Sets the external arc colour (thicker line).
- Parameters:
colour – a valid
wx.Colourobject. If defaulted toNone, the arc colour will be black.
- SetDirection(self, direction=None)¶
Sets the direction of advancing
SpeedMetervalue.- Parameters:
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.- Parameters:
colour – a valid
wx.Colourobject.
- SetFirstGradientColour(self, colour=None)¶
Sets the first gradient colour (near the ticks).
- Parameters:
colour – a valid
wx.Colourobject.
- SetHandColour(self, colour=None)¶
Sets the hand (arrow indicator) colour.
- Parameters:
colour – a valid
wx.Colourobject. If defaulted toNone, the arrow indicator will be red.
- SetHandStyle(self, style=None)¶
Sets the style for the hand (arrow indicator).
- Parameters:
style – by specifying “Hand”,
SpeedMeterwill draw a polygon that simulates the car speed control indicator. Using “Arrow” will forceSpeedMeterto draw a simple arrow. If defaulted toNone, “Hand” will be used.
- SetIntervalColours(self, colours=None)¶
Sets the colours for the intervals.
- Parameters:
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 toNone, 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).- Parameters:
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.- Parameters:
icon – a valid
wx.Bitmapobject.
- SetMiddleText(self, text=None)¶
Sets the text to be drawn near the center of
SpeedMeter.- Parameters:
text – the text to be drawn near the center of
SpeedMeter. If defaulted toNone, an empty string will be used.
- SetMiddleTextColour(self, colour=None)¶
Sets the colour for the text in the middle.
- Parameters:
colour – a valid
wx.Colourobject. If defaulted toNone, the text in the middle will be painted in blue.
- SetMiddleTextFont(self, font=None)¶
Sets the font for the text in the middle.
- Parameters:
font – a valid
wx.Fontobject. If defaulted toNone, some standard font will be generated.
- SetNumberOfSecondaryTicks(self, ticknum=None)¶
Sets the number of secondary (intermediate) ticks.
- Parameters:
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).
- Parameters:
colour – a valid
wx.Colourobject.
- SetShadowColour(self, colour=None)¶
Sets the hand’s shadow colour.
- Parameters:
colour – a valid
wx.Colourobject. If defaulted toNone, the shadow colour will be light grey.
- SetSpeedBackground(self, colour=None)¶
Sets the background colour outside the
SpeedMetercontrol.- Parameters:
colour – a valid
wx.Colourobject. If defaulted toNone, theSpeedMeterbackground will be taken from the system default.
- SetSpeedValue(self, value=None)¶
Sets the current value for
SpeedMeter.- Parameters:
value – a floating point number representing the current value. If defaulted to
None, theSpeedMetervalue will be the middle point of the control range.
- SetTicks(self, ticks=None)¶
Sets the ticks for
SpeedMeterintervals (main ticks string values).- Parameters:
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.
- Parameters:
colour – a valid
wx.Colourobject. If defaulted toNone, the ticks colour will be set as blue.