phoenix_title 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 Class Hierarchy

Inheritance diagram for class SpeedMeter:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


super_classes Known Superclasses

wx.lib.agw.speedmeter.BufferedWindow


method_summary Methods Summary

__init__

Default class constructor.

CircleCoords

Converts the input values into logical x, y coordinates.

Draw

Draws everything on the empty bitmap.

DrawExternalArc

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

GetAngleRange

Returns the range of existence for SpeedMeter.

GetArcColour

Returns the external arc colour.

GetDirection

Returns the direction of advancing SpeedMeter value.

GetFillerColour

Returns the partial filler colour.

GetFirstGradientColour

Returns the first gradient colour (near the ticks).

GetHandColour

Returns the hand (arrow indicator) colour.

GetHandStyle

Returns the style for the hand (arrow indicator).

GetIntersection

Used internally.

GetIntervalColours

Returns the colours for the intervals.

GetIntervals

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

GetMiddleIcon

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

GetMiddleIconDimens

Used internally.

GetMiddleText

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

GetMiddleTextColour

Returns the colour for the text in the middle.

GetMiddleTextFont

Returns the font for the text in the middle.

GetNumberOfSecondaryTicks

Returns the number of secondary (intermediate) ticks.

GetSecondGradientColour

Returns the first gradient colour (near the center).

GetShadowColour

Returns the hand’s shadow colour.

GetSpeedBackground

Returns the background colour outside the SpeedMeter control.

GetSpeedStyle

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

GetSpeedValue

Returns the current value for SpeedMeter.

GetTicks

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

GetTicksColour

Returns the ticks colour.

GetTicksFont

Returns the ticks font.

OnMouseMotion

Handles the wx.EVT_MOUSE_EVENTS event for SpeedMeter.

SetAngleRange

Sets the range of existence for SpeedMeter.

SetArcColour

Sets the external arc colour (thicker line).

SetDirection

Sets the direction of advancing SpeedMeter value.

SetFillerColour

Sets the partial filler colour.

SetFirstGradientColour

Sets the first gradient colour (near the ticks).

SetHandColour

Sets the hand (arrow indicator) colour.

SetHandStyle

Sets the style for the hand (arrow indicator).

SetIntervalColours

Sets the colours for the intervals.

SetIntervals

Sets the intervals for SpeedMeter (main ticks numeric values).

SetMiddleIcon

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

SetMiddleText

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

SetMiddleTextColour

Sets the colour for the text in the middle.

SetMiddleTextFont

Sets the font for the text in the middle.

SetNumberOfSecondaryTicks

Sets the number of secondary (intermediate) ticks.

SetSecondGradientColour

Sets the second gradient colour (near the center).

SetShadowColour

Sets the hand’s shadow colour.

SetSpeedBackground

Sets the background colour outside the SpeedMeter control.

SetSpeedValue

Sets the current value for SpeedMeter.

SetTicks

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

SetTicksColour

Sets the ticks colour.

SetTicksFont

Sets the ticks font.


api Class API

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


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 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 different 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 lib.fancytext for the tags.

  • bufferedstyle

    this value allows you to use the normal PaintDC or the double buffered drawing options:

    Buffered Styles

    Hex Value

    Description

    SM_NORMAL_DC

    0x0

    Uses the normal 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(self, radius, angle, centerX, centerY)

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(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:

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

Parameters:

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.

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.Colour object. If defaulted to None, the arc colour will be black.



SetDirection(self, direction=None)

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



SetFirstGradientColour(self, colour=None)

Sets the first gradient colour (near the ticks).

Parameters:

colour – a valid wx.Colour object.



SetHandColour(self, colour=None)

Sets the hand (arrow indicator) colour.

Parameters:

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

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(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 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).

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



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



SetMiddleTextColour(self, colour=None)

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(self, font=None)

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



SetShadowColour(self, colour=None)

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(self, colour=None)

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(self, value=None)

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(self, ticks=None)

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(self, colour=None)

Sets the ticks colour.

Parameters:

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



SetTicksFont(self, font=None)

Sets the ticks font.

Parameters:

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