.. wxPython Phoenix documentation

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

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

.. include:: headings.inc

.. currentmodule:: wx.lib.agw.pygauge

.. highlight:: python



.. _wx.lib.agw.pygauge.PyGauge:

==========================================================================================================================================
|phoenix_title|  **wx.lib.agw.pygauge.PyGauge**
==========================================================================================================================================

This class provides a visual alternative for :class:`Gauge`. It currently
only support determinate mode (see :meth:`PyGauge.SetValue() <PyGauge.SetValue>` and
:meth:`PyGauge.SetRange() <PyGauge.SetRange>`).



|

|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>PyGauge</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.pygauge.PyGauge_inheritance.png" alt="Inheritance diagram of PyGauge" 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.lib.agw.pygauge.PyGauge.html" title="wx.lib.agw.pygauge.PyGauge" alt="" coords="11,315,215,344"/> <area shape="rect" id="node2" href="wx.Window.html" title="wx.Window" alt="" coords="69,237,157,267"/> <area shape="rect" id="node3" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="5,5,107,35"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="57,83,168,112"/> <area shape="rect" id="node6" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="53,160,173,189"/> <area shape="rect" id="node5" href="wx.Object.html" title="wx.Object" alt="" coords="131,5,212,35"/> </map> 
   </p>

|


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

|

.. figure:: _static/images/widgets/fullsize/wxmsw/wx.lib.agw.pygauge.pygauge.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/../no_appearance.png
   :alt: wxGTK
   :figclass: floatcenter

   **wxGTK**


|




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

:class:`wx.Window`

|


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

================================================================================ ================================================================================
:meth:`~wx.lib.agw.pygauge.PyGauge.__init__`                                     Default class constructor.
:meth:`~wx.lib.agw.pygauge.PyGauge.DoGetBestSize`                                Gets the size which best suits :class:`PyGauge`: for a control, it would be
:meth:`~wx.lib.agw.pygauge.PyGauge.GetBarColour`                                 Returns the :class:`PyGauge` main bar colour.
:meth:`~wx.lib.agw.pygauge.PyGauge.GetBarGradient`                               Returns a tuple containing the gradient start and end colours.
:meth:`~wx.lib.agw.pygauge.PyGauge.GetBorderColour`                              Returns the :class:`PyGauge` border colour.
:meth:`~wx.lib.agw.pygauge.PyGauge.GetBorderPadding`                             Gets the border padding.
:meth:`~wx.lib.agw.pygauge.PyGauge.GetRange`                                     Returns the maximum value of the gauge.
:meth:`~wx.lib.agw.pygauge.PyGauge.GetValue`                                     Returns the current position of the gauge.
:meth:`~wx.lib.agw.pygauge.PyGauge.OnEraseBackground`                            Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`PyGauge`.
:meth:`~wx.lib.agw.pygauge.PyGauge.OnPaint`                                      Handles the ``wx.EVT_PAINT`` event for :class:`PyGauge`.
:meth:`~wx.lib.agw.pygauge.PyGauge.OnTimer`                                      Handles the ``wx.EVT_TIMER`` event for :class:`PyGauge`.
:meth:`~wx.lib.agw.pygauge.PyGauge.SetBarColour`                                 Sets the :class:`PyGauge` main bar colour.
:meth:`~wx.lib.agw.pygauge.PyGauge.SetBarGradient`                               Sets the bar gradient.
:meth:`~wx.lib.agw.pygauge.PyGauge.SetBorderColour`                              Sets the :class:`PyGauge` border colour.
:meth:`~wx.lib.agw.pygauge.PyGauge.SetBorderPadding`                             Sets the border padding.
:meth:`~wx.lib.agw.pygauge.PyGauge.SetDrawValue`                                 Sets whether percentage or current value should be drawn on the gauge for precise indication.
:meth:`~wx.lib.agw.pygauge.PyGauge.SetRange`                                     Sets the range of the gauge. The gauge length is its
:meth:`~wx.lib.agw.pygauge.PyGauge.SetValue`                                     Sets the current position of the gauge.
:meth:`~wx.lib.agw.pygauge.PyGauge.SortForDisplay`                               Internal method which sorts things so we draw the longest bar first.
:meth:`~wx.lib.agw.pygauge.PyGauge.Update`                                       Update the gauge by adding `value` to it over `time` milliseconds. The `time` parameter
================================================================================ ================================================================================


|


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


.. class:: PyGauge(wx.Window)

   This class provides a visual alternative for :class:`Gauge`. It currently
   only support determinate mode (see :meth:`PyGauge.SetValue() <PyGauge.SetValue>` and
   :meth:`PyGauge.SetRange() <PyGauge.SetRange>`).

   .. method:: __init__(self, parent, id=wx.ID_ANY, range=100, pos=wx.DefaultPosition, size=(-1,30), style=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 `style`: the underlying :class:`wx.Window` window style.


   .. method:: DoGetBestSize(self)

      Gets the size which best suits :class:`PyGauge`: for a control, it would be
      the minimal size which doesn't truncate the control, for a panel - the
      same size as it would have after a call to `Fit()`.
      
      :note: Overridden from :class:`wx.Window`.


   .. method:: GetBarColour(self)

      Returns the :class:`PyGauge` main bar colour. 


   .. method:: GetBarGradient(self)

      Returns a tuple containing the gradient start and end colours. 


   .. method:: GetBorderColour(self)

      Returns the :class:`PyGauge` border colour. 


   .. method:: GetBorderPadding(self)

      Gets the border padding. 


   .. method:: GetRange(self)

      Returns the maximum value of the gauge. 


   .. method:: GetValue(self)

      Returns the current position of the gauge. 


   .. method:: OnEraseBackground(self, event)

      Handles the ``wx.EVT_ERASE_BACKGROUND`` event for :class:`PyGauge`.
      
      :param `event`: a :class:`EraseEvent` event to be processed.
      
      :note: This method is intentionally empty to reduce flicker.


   .. method:: OnPaint(self, event)

      Handles the ``wx.EVT_PAINT`` event for :class:`PyGauge`.
      
      :param `event`: a :class:`PaintEvent` event to be processed.


   .. method:: OnTimer(self,event)

      Handles the ``wx.EVT_TIMER`` event for :class:`PyGauge`.
      
      :param `event`: a :class:`TimerEvent` event to be processed.


   .. method:: SetBarColour(self, colour)

      Sets the :class:`PyGauge` main bar colour.
      
      :param `colour`: an instance of :class:`wx.Colour`.


   .. method:: SetBarGradient(self, gradient)

      Sets the bar gradient.
      
      :param `gradient`: a tuple containing the gradient start and end colours.
      
      :note: This overrides the bar colour previously set with :meth:`PyGauge.SetBarColour`.


   .. method:: SetBorderColour(self, colour)

      Sets the :class:`PyGauge` border colour.
      
      :param `colour`: an instance of :class:`wx.Colour`.


   .. method:: SetBorderPadding(self, padding)

      Sets the border padding.
      
      :param `padding`: pixels between the border and the progress bar.


   .. method:: SetDrawValue(self, draw=True, drawPercent=True, font=None, colour=wx.BLACK, formatString=None)

      Sets whether percentage or current value should be drawn on the gauge for precise indication.
      
      :param bool `draw`: a boolean value, which if ``True`` tells to start drawing value or percentage.
       If set to ``False`` nothing will be drawn and other parameters will be ignored;
      :param bool `drawPercent`: a boolean value which indicates that a percent should be drawn instead
       of value passed in :meth:`SetValue`;
      :param wx.Font `font`: a font with which indication should be drawn, if ``None``, then ``wx.NORMAL_FONT``
       will be used. Usually text would be displayed centered in the control, but if the text font is too large
       to be displayed (either in width or height) the corresponding coordinate will be set to zero;
      :param wx.Colour `colour`: the colour with which indication should be drawn, if ``None`` then ``wx.BLACK`` will be used;
      :param string `formatString`: a string specifying format of the indication (should have one and only one
       number placeholder). If set to ``None``, will use ``{:.0f}`` format string for values and ``{:.0f}%``
       format string for percentages. As described in http://docs.python.org/library/string.html#format-specification-mini-language.
      
      .. note:: `formatString` will override addition of percent sign (after value) even if `drawPercent` is ``True``.
      
      .. versionadded:: 0.9.7


   .. method:: SetRange(self, range)

      Sets the range of the gauge. The gauge length is its
      value as a proportion of the range.
      
      :param `range`: The maximum value of the gauge.


   .. method:: SetValue(self, value)

      Sets the current position of the gauge.
      
      :param `value`: an integer specifying the current position of the gauge.


   .. method:: SortForDisplay(self)

      Internal method which sorts things so we draw the longest bar first. 


   .. method:: Update(self, value, time=0)

      Update the gauge by adding `value` to it over `time` milliseconds. The `time` parameter
      **must** be a multiple of 50 milliseconds.
      
      :param `value`: The value to be added to the gauge;
      :param `time`: The length of time in milliseconds that it will take to move the gauge.


