.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. currentmodule:: wx.lib.agw.speedmeter

.. highlight:: python



.. _wx.lib.agw.speedmeter.SpeedMeter:

==========================================================================================================================================
|phoenix_title|  **wx.lib.agw.speedmeter.SpeedMeter**
==========================================================================================================================================

:class:`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
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>SpeedMeter</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.lib.agw.speedmeter.SpeedMeter_inheritance.png" alt="Inheritance diagram of SpeedMeter" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="32,5,133,35"/> <area shape="rect" id="node2" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="84,83,195,112"/> <area shape="rect" id="node6" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="79,160,200,189"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="157,5,239,35"/> <area shape="rect" id="node4" href="wx.lib.agw.speedmeter.BufferedWindow.html" title="wx.lib.agw.speedmeter.BufferedWindow" alt="" coords="5,315,275,344"/> <area shape="rect" id="node7" href="wx.lib.agw.speedmeter.SpeedMeter.html" title="wx.lib.agw.speedmeter.SpeedMeter" alt="" coords="17,392,263,421"/> <area shape="rect" id="node5" href="wx.Window.html" title="wx.Window" alt="" coords="95,237,184,267"/> </map> 
   </p>

|


|appearance| Control Appearance
===============================

|

.. figure:: _static/images/widgets/fullsize/wxmsw/wx.lib.agw.speedmeter.speedmeter.png
   :alt: wxMSW
   :figclass: floatleft

   **wxMSW**


.. figure:: _static/images/widgets/fullsize/wxmac/../no_appearance.png
   :alt: wxMAC
   :figclass: floatright

   **wxMAC**


.. figure:: _static/images/widgets/fullsize/wxgtk/wx.lib.agw.speedmeter.speedmeter.png
   :alt: wxGTK
   :figclass: floatcenter

   **wxGTK**


|




|super_classes| Known Superclasses
==================================

:class:`wx.lib.agw.speedmeter.BufferedWindow`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.__init__`                               Default class constructor.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.CircleCoords`                           Converts the input values into logical x, y coordinates.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.Draw`                                   Draws everything on the empty bitmap.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.DrawExternalArc`                        Specify wheter or not you wish to draw the external (thicker) arc.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetAngleRange`                          Returns the range of existence for :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetArcColour`                           Returns the external arc colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetDirection`                           Returns the direction of advancing :class:`SpeedMeter` value.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetFillerColour`                        Returns the partial filler colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetFirstGradientColour`                 Returns the first gradient colour (near the ticks).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetHandColour`                          Returns the hand (arrow indicator) colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetHandStyle`                           Returns the style for the hand (arrow indicator).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetIntersection`                        Used internally.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetIntervalColours`                     Returns the colours for the intervals.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetIntervals`                           Returns the intervals for :class:`SpeedMeter`, a Python list of main ticks displayed.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetMiddleIcon`                          Returns the icon to be drawn near the center of :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetMiddleIconDimens`                    Used internally.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetMiddleText`                          Returns the text to be drawn near the center of :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetMiddleTextColour`                    Returns the colour for the text in the middle.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetMiddleTextFont`                      Returns the font for the text in the middle.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetNumberOfSecondaryTicks`              Returns the number of secondary (intermediate) ticks.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetSecondGradientColour`                Returns the first gradient colour (near the center).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetShadowColour`                        Returns the hand's shadow colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetSpeedBackground`                     Returns the background colour outside the :class:`SpeedMeter` control.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetSpeedStyle`                          Returns a list of strings and a list of integers containing the styles.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetSpeedValue`                          Returns the current value for :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetTicks`                               Returns the ticks for :class:`SpeedMeter` intervals (main ticks string values).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetTicksColour`                         Returns the ticks colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.GetTicksFont`                           Returns the ticks font.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.OnMouseMotion`                          Handles the ``wx.EVT_MOUSE_EVENTS`` event for :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetAngleRange`                          Sets the range of existence for :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetArcColour`                           Sets the external arc colour (thicker line).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetDirection`                           Sets the direction of advancing :class:`SpeedMeter` value.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetFillerColour`                        Sets the partial filler colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetFirstGradientColour`                 Sets the first gradient colour (near the ticks).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetHandColour`                          Sets the hand (arrow indicator) colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetHandStyle`                           Sets the style for the hand (arrow indicator).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetIntervalColours`                     Sets the colours for the intervals.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetIntervals`                           Sets the intervals for :class:`SpeedMeter` (main ticks numeric values).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetMiddleIcon`                          Sets the icon to be drawn near the center of :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetMiddleText`                          Sets the text to be drawn near the center of :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetMiddleTextColour`                    Sets the colour for the text in the middle.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetMiddleTextFont`                      Sets the font for the text in the middle.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetNumberOfSecondaryTicks`              Sets the number of secondary (intermediate) ticks.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetSecondGradientColour`                Sets the second gradient colour (near the center).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetShadowColour`                        Sets the hand's shadow colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetSpeedBackground`                     Sets the background colour outside the :class:`SpeedMeter` control.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetSpeedValue`                          Sets the current value for :class:`SpeedMeter`.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetTicks`                               Sets the ticks for :class:`SpeedMeter` intervals (main ticks string values).
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetTicksColour`                         Sets the ticks colour.
:meth:`~wx.lib.agw.speedmeter.SpeedMeter.SetTicksFont`                           Sets the ticks font.
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: SpeedMeter(BufferedWindow)

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

   .. method:: __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.
      
      :param `parent`: parent window. Must not be ``None``;
      :param `id`: window identifier. A value of -1 indicates a default value;
      :param `pos`: the control position. A value of (-1, -1) indicates a default position,
       chosen by either the windowing system or wxPython, depending on platform;
      :param `size`: the control size. A value of (-1, -1) indicates a default size,
       chosen by either the windowing system or wxPython, depending on platform;
      :param `agwStyle`: this value specifies the :class:`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 :mod:`lib.fancytext` for the tags.
       =========================== =========== ==================================================
      
      :param `bufferedstyle`: this value allows you to use the normal :class:`PaintDC` or the
       double buffered drawing options:
      
       =========================== =========== ==================================================
       Buffered Styles             Hex Value   Description
       =========================== =========== ==================================================
       ``SM_NORMAL_DC``                    0x0 Uses the normal :class:`PaintDC`
       ``SM_BUFFERED_DC``                  0x1 Uses the double buffered drawing style
       =========================== =========== ==================================================
      
      :param `mousestyle`: this value allows you to use the mouse to change the :class:`SpeedMeter`
       value interactively with left click/drag events. If set to ``SM_MOUSE_TRACK``, the mouse
       left click/drag allow you to change the :class:`SpeedMeter` value interactively.


   .. method:: CircleCoords(self, radius, angle, centerX, centerY)

      Converts the input values into logical x, y coordinates.
      
      :param `radius`: the :class:`SpeedMeter` radius;
      :param `angle`: the angular position of the mouse;
      :param `centerX`: the `x` position of the :class:`SpeedMeter` center;
      :param `centerX`: the `y` position of the :class:`SpeedMeter` center.


   .. method:: Draw(self, dc)

      Draws everything on the empty bitmap.
      Here all the chosen styles are applied.
      
      :param `dc`: an instance of :class:`wx.DC`.


   .. method:: DrawExternalArc(self, draw=True)

      Specify wheter or not you wish to draw the external (thicker) arc.
      
      :param `draw`: ``True`` to draw the external arc, ``False`` otherwise.


   .. method:: GetAngleRange(self)

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


   .. method:: GetArcColour(self)

      Returns the external arc colour.


   .. method:: GetDirection(self)

      Returns the direction of advancing :class:`SpeedMeter` value.


   .. method:: GetFillerColour(self)

      Returns the partial filler colour.


   .. method:: GetFirstGradientColour(self)

      Returns the first gradient colour (near the ticks). 


   .. method:: GetHandColour(self)

      Returns the hand (arrow indicator) colour.


   .. method:: GetHandStyle(self)

      Returns the style for the hand (arrow indicator).


   .. method:: GetIntersection(self, current, intervals)

      Used internally. 


   .. method:: GetIntervalColours(self)

      Returns the colours for the intervals.


   .. method:: GetIntervals(self)

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


   .. method:: GetMiddleIcon(self)

      Returns the icon to be drawn near the center of :class:`SpeedMeter`. 


   .. method:: GetMiddleIconDimens(self)

      Used internally. 


   .. method:: GetMiddleText(self)

      Returns the text to be drawn near the center of :class:`SpeedMeter`. 


   .. method:: GetMiddleTextColour(self)

      Returns the colour for the text in the middle.


   .. method:: GetMiddleTextFont(self)

      Returns the font for the text in the middle.


   .. method:: GetNumberOfSecondaryTicks(self)

      Returns the number of secondary (intermediate) ticks. 


   .. method:: GetSecondGradientColour(self)

      Returns the first gradient colour (near the center). 


   .. method:: GetShadowColour(self)

      Returns the hand's shadow colour.


   .. method:: GetSpeedBackground(self)

      Returns the background colour outside the :class:`SpeedMeter` control.


   .. method:: GetSpeedStyle(self)

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


   .. method:: GetSpeedValue(self)

      Returns the current value for :class:`SpeedMeter`. 


   .. method:: GetTicks(self)

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


   .. method:: GetTicksColour(self)

      Returns the ticks colour.


   .. method:: GetTicksFont(self)

      Returns the ticks font.


   .. method:: OnMouseMotion(self, event)

      Handles the ``wx.EVT_MOUSE_EVENTS`` event for :class:`SpeedMeter`.
      
      :param `event`: a :class:`MouseEvent` event to be processed.
      
      :note: Here only left clicks/drags are involved. Should :class:`SpeedMeter`
       have something more?


   .. method:: SetAngleRange(self, start=0, end=pi)

      Sets the range of existence for :class:`SpeedMeter`.
      
      :param `start`: the starting angle, in radians;
      :param `end`: the ending angle, in radians.


   .. method:: SetArcColour(self, colour=None)

      Sets the external arc colour (thicker line).
      
      :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the arc
       colour will be black.


   .. method:: SetDirection(self, direction=None)

      Sets the direction of advancing :class:`SpeedMeter` value.
      
      :param `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.


   .. method:: 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 :class:`SpeedMeter`.
      
      :param `colour`: a valid :class:`wx.Colour` object.


   .. method:: SetFirstGradientColour(self, colour=None)

      Sets the first gradient colour (near the ticks).
      
      :param `colour`: a valid :class:`wx.Colour` object.


   .. method:: SetHandColour(self, colour=None)

      Sets the hand (arrow indicator) colour.
      
      :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the arrow
       indicator will be red.


   .. method:: SetHandStyle(self, style=None)

      Sets the style for the hand (arrow indicator).
      
      :param `style`: by specifying "Hand", :class:`SpeedMeter` will draw a polygon
       that simulates the car speed control indicator. Using "Arrow" will force
       :class:`SpeedMeter` to draw a simple arrow. If defaulted to ``None``, "Hand" will
       be used.
       


   .. method:: SetIntervalColours(self, colours=None)

      Sets the colours for the intervals.
      
      :param `colours`: a Python list of colours. The length of this list should be
       the same as the number of circle sectors in :class:`SpeedMeter`. If defaulted to ``None``,
       all the intervals will have a white colour.
      
      :note: Every interval (circle sector) should have a colour.


   .. method:: SetIntervals(self, intervals=None)

      Sets the intervals for :class:`SpeedMeter` (main ticks numeric values).
      
      :param `intervals`: a Python list of main ticks to be displayed. If defaulted
       to ``None``, the list `[0, 50, 100]` is used.


   .. method:: SetMiddleIcon(self, icon)

      Sets the icon to be drawn near the center of :class:`SpeedMeter`.
      
      :param `icon`: a valid :class:`wx.Bitmap` object.


   .. method:: SetMiddleText(self, text=None)

      Sets the text to be drawn near the center of :class:`SpeedMeter`.
      
      :param `text`: the text to be drawn near the center of :class:`SpeedMeter`. If
       defaulted to ``None``, an empty string will be used.


   .. method:: SetMiddleTextColour(self, colour=None)

      Sets the colour for the text in the middle.
      
      :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the text
       in the middle will be painted in blue.


   .. method:: SetMiddleTextFont(self, font=None)

      Sets the font for the text in the middle.
      
      :param `font`: a valid :class:`wx.Font` object. If defaulted to ``None``, some
       standard font will be generated.


   .. method:: SetNumberOfSecondaryTicks(self, ticknum=None)

      Sets the number of secondary (intermediate) ticks.
      
      :param `ticknum`: the number of intermediate ticks. If defaulted to ``None``,
       3 ticks are used.


   .. method:: SetSecondGradientColour(self, colour=None)

      Sets the second gradient colour (near the center).
      
      :param `colour`: a valid :class:`wx.Colour` object.


   .. method:: SetShadowColour(self, colour=None)

      Sets the hand's shadow colour.
      
      :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the shadow
       colour will be light grey.


   .. method:: SetSpeedBackground(self, colour=None)

      Sets the background colour outside the :class:`SpeedMeter` control.
      
      :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the
       :class:`SpeedMeter` background will be taken from the system default.


   .. method:: SetSpeedValue(self, value=None)

      Sets the current value for :class:`SpeedMeter`.
      
      :param `value`: a floating point number representing the current value. If defaulted
       to ``None``, the :class:`SpeedMeter` value will be the middle point of the control range.


   .. method:: SetTicks(self, ticks=None)

      Sets the ticks for :class:`SpeedMeter` intervals (main ticks string values).
      
      :param `ticks`: a Python list of strings, representing the ticks values.
       If defaulted to ``None``, the ticks will be taken from the interval values.


   .. method:: SetTicksColour(self, colour=None)

      Sets the ticks colour.
      
      :param `colour`: a valid :class:`wx.Colour` object. If defaulted to ``None``, the
       ticks colour will be set as blue.


   .. method:: SetTicksFont(self, font=None)

      Sets the ticks font.
      
      :param `font`: a valid :class:`wx.Font` object. If defaulted to ``None``, some standard
       font will be chosen automatically.


