AGW Logo

agw_title 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.

hierarchy Inheritance Diagram

Inheritance diagram for: SpeedMeter

Inheritance diagram of SpeedMeter


supclasses Known Superclasses


appearance Control Appearance


SpeedMeter

SpeedMeter


method_summary Methods Summary

__init__Default class constructor.
CircleCoordsConverts the input values into logical x, y coordinates.
DrawDraws everything on the empty bitmap.
DrawExternalArcSpecify wheter or not you wish to draw the external (thicker) arc.
GetAngleRangeReturns the range of existence for SpeedMeter.
GetArcColourReturns the external arc colour.
GetDirectionReturns the direction of advancing SpeedMeter value.
GetFillerColourReturns the partial filler colour.
GetFirstGradientColourReturns the first gradient colour (near the ticks).
GetHandColourReturns the hand (arrow indicator) colour.
GetHandStyleReturns the style for the hand (arrow indicator).
GetIntersectionUsed internally.
GetIntervalColoursReturns the colours for the intervals.
GetIntervalsReturns the intervals for SpeedMeter, a Python list of main ticks displayed.
GetMiddleIconReturns the icon to be drawn near the center of SpeedMeter.
GetMiddleIconDimensUsed internally.
GetMiddleTextReturns the text to be drawn near the center of SpeedMeter.
GetMiddleTextColourReturns the colour for the text in the middle.
GetMiddleTextFontReturns the font for the text in the middle.
GetNumberOfSecondaryTicksReturns the number of secondary (intermediate) ticks.
GetSecondGradientColourReturns the first gradient colour (near the center).
GetShadowColourReturns the hand’s shadow colour.
GetSpeedBackgroundReturns the background colour outside the SpeedMeter control.
GetSpeedStyleReturns a list of strings and a list of integers containing the styles.
GetSpeedValueReturns the current value for SpeedMeter.
GetTicksReturns the ticks for SpeedMeter intervals (main ticks string values).
GetTicksColourReturns the ticks colour.
GetTicksFontReturns the ticks font.
OnMouseMotionHandles the wx.EVT_MOUSE_EVENTS event for SpeedMeter.
SetAngleRangeSets the range of existence for SpeedMeter.
SetArcColourSets the external arc colour (thicker line).
SetDirectionSets the direction of advancing SpeedMeter value.
SetFillerColourSets the partial filler colour.
SetFirstGradientColourSets the first gradient colour (near the ticks).
SetHandColourSets the hand (arrow indicator) colour.
SetHandStyleSets the style for the hand (arrow indicator).
SetIntervalColoursSets the colours for the intervals.
SetIntervalsSets the intervals for SpeedMeter (main ticks numeric values).
SetMiddleIconSets the icon to be drawn near the center of SpeedMeter.
SetMiddleTextSets the text to be drawn near the center of SpeedMeter.
SetMiddleTextColourSets the colour for the text in the middle.
SetMiddleTextFontSets the font for the text in the middle.
SetNumberOfSecondaryTicksSets the number of secondary (intermediate) ticks.
SetSecondGradientColourSets the second gradient colour (near the center).
SetShadowColourSets the hand’s shadow colour.
SetSpeedBackgroundSets the background colour outside the SpeedMeter control.
SetSpeedValueSets the current value for SpeedMeter.
SetTicksSets the ticks for SpeedMeter intervals (main ticks string values).
SetTicksColourSets the ticks colour.
SetTicksFontSets the ticks font.

API Class API

class SpeedMeter(BufferedWindow)[source]

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__(parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=SM_DRAW_HAND, bufferedstyle=SM_BUFFERED_DC, mousestyle=0)[source]

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 SpeedMeter styles, and can be a combination of the following bits:


    Window Styles Hex Value Description
    SM_ROTATE_TEXT 0x1 Draws the ticks rotated: the ticks are rotated accordingly to the tick marks positions.
    SM_DRAW_SECTORS 0x2 Different intervals are painted in differend colours (every sector of the circle has its own colour).
    SM_DRAW_PARTIAL_SECTORS 0x4 Every interval has its own colour, but only a circle corona is painted near the ticks.
    SM_DRAW_HAND 0x8 The hand (arrow indicator) is drawn.
    SM_DRAW_SHADOW 0x10 A shadow for the hand is drawn.
    SM_DRAW_PARTIAL_FILLER 0x20 A circle corona that follows the hand position is drawn near the ticks.
    SM_DRAW_SECONDARY_TICKS 0x40 Intermediate (smaller) ticks are drawn between principal ticks.
    SM_DRAW_MIDDLE_TEXT 0x80 Some text is printed in the middle of the control near the center.
    SM_DRAW_MIDDLE_ICON 0x100 An icon is drawn in the middle of the control near the center.
    SM_DRAW_GRADIENT 0x200 A gradient of colours will fill the control.
    SM_DRAW_FANCY_TICKS 0x400 With this style you can use xml tags to create some custom text and draw it at the ticks position. See wx.lib.fancytext for the tags.
  • bufferedstyle – this value allows you to use the normal wx.PaintDC or the double buffered drawing options:


    Buffered Styles Hex Value Description
    SM_NORMAL_DC 0x0 Uses the normal wx.PaintDC
    SM_BUFFERED_DC 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(radius, angle, centerX, centerY)[source]

Converts the input values into logical x, y coordinates.

Parameters:
  • 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(dc)[source]

Draws everything on the empty bitmap. Here all the chosen styles are applied.

Parameters:dc – an instance of wx.DC.


DrawExternalArc(draw=True)[source]

Specify wheter or not you wish to draw the external (thicker) arc.

Parameters:drawTrue to draw the external arc, False otherwise.


GetAngleRange()[source]

Returns the range of existence for SpeedMeter. The returned values are in radians.



GetArcColour()[source]

Returns the external arc colour.



GetDirection()[source]

Returns the direction of advancing SpeedMeter value.



GetFillerColour()[source]

Returns the partial filler colour.



GetFirstGradientColour()[source]

Returns the first gradient colour (near the ticks).



GetHandColour()[source]

Returns the hand (arrow indicator) colour.



GetHandStyle()[source]

Returns the style for the hand (arrow indicator).



GetIntersection(current, intervals)[source]

Used internally.



GetIntervalColours()[source]

Returns the colours for the intervals.



GetIntervals()[source]

Returns the intervals for SpeedMeter, a Python list of main ticks displayed.



GetMiddleIcon()[source]

Returns the icon to be drawn near the center of SpeedMeter.



GetMiddleIconDimens()[source]

Used internally.



GetMiddleText()[source]

Returns the text to be drawn near the center of SpeedMeter.



GetMiddleTextColour()[source]

Returns the colour for the text in the middle.



GetMiddleTextFont()[source]

Returns the font for the text in the middle.



GetNumberOfSecondaryTicks()[source]

Returns the number of secondary (intermediate) ticks.



GetSecondGradientColour()[source]

Returns the first gradient colour (near the center).



GetShadowColour()[source]

Returns the hand’s shadow colour.



GetSpeedBackground()[source]

Returns the background colour outside the SpeedMeter control.



GetSpeedStyle()[source]

Returns a list of strings and a list of integers containing the styles.



GetSpeedValue()[source]

Returns the current value for SpeedMeter.



GetTicks()[source]

Returns the ticks for SpeedMeter intervals (main ticks string values).



GetTicksColour()[source]

Returns the ticks colour.



GetTicksFont()[source]

Returns the ticks font.



OnMouseMotion(event)[source]

Handles the wx.EVT_MOUSE_EVENTS event for SpeedMeter.

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

Note

Here only left clicks/drags are involved. Should SpeedMeter have something more?



SetAngleRange(start=0, end=3.141592653589793)[source]

Sets the range of existence for SpeedMeter.

Parameters:
  • start – the starting angle, in radians;
  • end – the ending angle, in radians.


SetArcColour(colour=None)[source]

Sets the external arc colour (thicker line).

Parameters:colour – a valid wx.Colour object. If defaulted to None, the arc colour will be black.


SetDirection(direction=None)[source]

Sets the direction of advancing SpeedMeter value.

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(colour=None)[source]

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.Colour object.



SetFirstGradientColour(colour=None)[source]

Sets the first gradient colour (near the ticks).

Parameters:colour – a valid wx.Colour object.



SetHandColour(colour=None)[source]

Sets the hand (arrow indicator) colour.

Parameters:colour – a valid wx.Colour object. If defaulted to None, the arrow indicator will be red.



SetHandStyle(style=None)[source]

Sets the style for the hand (arrow indicator).

Parameters: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(colours=None)[source]

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 to None, all the intervals will have a white colour.

Note

Every interval (circle sector) should have a colour.



SetIntervals(intervals=None)[source]

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(icon)[source]

Sets the icon to be drawn near the center of SpeedMeter.

Parameters:icon – a valid wx.Bitmap object.


SetMiddleText(text=None)[source]

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 to None, an empty string will be used.


SetMiddleTextColour(colour=None)[source]

Sets the colour for the text in the middle.

Parameters:colour – a valid wx.Colour object. If defaulted to None, the text in the middle will be painted in blue.



SetMiddleTextFont(font=None)[source]

Sets the font for the text in the middle.

Parameters:font – a valid wx.Font object. If defaulted to None, some standard font will be generated.


SetNumberOfSecondaryTicks(ticknum=None)[source]

Sets the number of secondary (intermediate) ticks.

Parameters:ticknum – the number of intermediate ticks. If defaulted to None, 3 ticks are used.


SetSecondGradientColour(colour=None)[source]

Sets the second gradient colour (near the center).

Parameters:colour – a valid wx.Colour object.



SetShadowColour(colour=None)[source]

Sets the hand’s shadow colour.

Parameters:colour – a valid wx.Colour object. If defaulted to None, the shadow colour will be light grey.



SetSpeedBackground(colour=None)[source]

Sets the background colour outside the SpeedMeter control.

Parameters:colour – a valid wx.Colour object. If defaulted to None, the SpeedMeter background will be taken from the system default.



SetSpeedValue(value=None)[source]

Sets the current value for SpeedMeter.

Parameters: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(ticks=None)[source]

Sets the ticks for SpeedMeter intervals (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(colour=None)[source]

Sets the ticks colour.

Parameters:colour – a valid wx.Colour object. If defaulted to None, the ticks colour will be set as blue.



SetTicksFont(font=None)[source]

Sets the ticks font.

Parameters:font – a valid wx.Font object. If defaulted to None, some standard font will be chosen automatically.

Tree

Table Of Contents

Previous topic

BufferedWindow

Next topic

SVN Revision 68362 For speedmeter