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

.. module:: wx.lib.agw.peakmeter

.. currentmodule:: wx.lib.agw.peakmeter

.. highlight:: python



.. _wx.lib.agw.peakmeter:

==========================================================================================================================================
|phoenix_title|  **wx.lib.agw.peakmeter**
==========================================================================================================================================

:class:`~wx.lib.agw.peakmeter.PeakMeterCtrl` mimics the behaviour of equalizers that are usually found in stereos
and MP3 players.


Description
===========

:class:`PeakMeterCtrl` mimics the behaviour of equalizers that are usually found in stereos
and MP3 players. This widgets supports:

* Vertical and horizontal led bands;
* Settings number of bands and leds per band;
* Possibility to change the colour for low/medium/high band frequencies;
* Falloff effects;
* Showing a background grid for the bands.

And a lot more. Check the demo for an almost complete review of the functionalities.


Usage
=====

Usage example::

    import wx
    import random

    import wx.lib.agw.peakmeter as PM

    class MyFrame(wx.Frame):

        def __init__(self, parent):

            wx.Frame.__init__(self, parent, -1, "PeakMeterCtrl Demo")

            panel = wx.Panel(self)

            # Initialize Peak Meter control 1
            self.vertPeak = PM.PeakMeterCtrl(panel, -1, style=wx.SIMPLE_BORDER, agwStyle=PM.PM_VERTICAL)
            # Initialize Peak Meter control 2
            self.horzPeak = PM.PeakMeterCtrl(panel, -1, style=wx.SUNKEN_BORDER, agwStyle=PM.PM_HORIZONTAL)

            self.vertPeak.SetMeterBands(10, 15)
            self.horzPeak.SetMeterBands(10, 15)

            # Layout the two PeakMeterCtrl
            mainSizer = wx.BoxSizer(wx.HORIZONTAL)
            mainSizer.Add(self.vertPeak, 0, wx.EXPAND | wx.ALL, 15)
            mainSizer.Add(self.horzPeak, 0, wx.EXPAND | wx.ALL, 15)

            panel.SetSizer(mainSizer)
            mainSizer.Layout()

            self.timer = wx.Timer(self)
            self.Bind(wx.EVT_TIMER, self.OnTimer)

            wx.CallLater(500, self.Start)


        def Start(self):
            ''' Starts the PeakMeterCtrl. '''

            self.timer.Start(1000//2)            # 2 fps

            self.vertPeak.Start(1000//18)        # 18 fps
            self.horzPeak.Start(1000//20)        # 20 fps


        def OnTimer(self, event):
            '''
            Handles the ``wx.EVT_TIMER`` event for :class:`PeakMeterCtrl`.

            :param `event`: a :class:`TimerEvent` event to be processed.
            '''

            # Generate 15 random number and set them as data for the meter
            nElements = 15
            arrayData = []

            for i in xrange(nElements):
                nRandom = random.randint(0, 100)
                arrayData.append(nRandom)

            self.vertPeak.SetData(arrayData, 0, nElements)
            self.horzPeak.SetData(arrayData, 0, nElements)


    # our normal wxApp-derived class, as usual

    app = wx.App(0)

    frame = MyFrame(None)
    app.SetTopWindow(frame)
    frame.Show()

    app.MainLoop()



Supported Platforms
===================

:class:`PeakMeterCtrl` has been tested on the following platforms:
  * Windows (Windows XP).


Window Styles
=============

This class supports the following window styles:

======================== =========== ========================================================
Window Styles            Hex Value   Description
======================== =========== ========================================================
``PM_HORIZONTAL``        0x0         Shows horizontal bands in :class:`PeakMeterCtrl`.
``PM_VERTICAL``          0x1         Shows vertical bands in :class:`PeakMeterCtrl`.
``PM_VERTICAL_INVERTED`` 0x2         Shows inverted vertical bands in :class:`PeakMeterCtrl`.
======================== =========== ========================================================


Events Processing
=================

`No custom events are available for this class.`


License And Version
===================

:class:`PeakMeterCtrl` is distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 31 Jul 2014, 21.00 GMT

Version 0.4


|function_summary| Functions Summary
====================================

================================================================================ ================================================================================
:func:`~wx.lib.agw.peakmeter.DarkenColour`                                       Darkens a colour.
:func:`~wx.lib.agw.peakmeter.InRange`                                            Returns whether the value `val` is between `valMin` and `valMax`.
:func:`~wx.lib.agw.peakmeter.LightenColour`                                      Lightens a colour.
================================================================================ ================================================================================


|


|class_summary| Classes Summary
===============================

================================================================================ ================================================================================
:ref:`~wx.lib.agw.peakmeter.PeakMeterCtrl`                                       The main :class:`PeakMeterCtrl` implementation.
:ref:`~wx.lib.agw.peakmeter.PeakMeterData`                                       A simple class which holds data for our :class:`PeakMeterCtrl`.
================================================================================ ================================================================================


|


.. toctree::
   :maxdepth: 1
   :hidden:

   wx.lib.agw.peakmeter.PeakMeterCtrl
   wx.lib.agw.peakmeter.PeakMeterData





Functions
------------

.. function:: DarkenColour(crColour, byReduceVal)

   Darkens a colour.
   
   :param `crColour`: a valid :class:`wx.Colour` object;
   :param `byReduceVal`: an integer specifying the amount for which the input
    colour should be darkened.


.. function:: InRange(val, valMin, valMax)

   Returns whether the value `val` is between `valMin` and `valMax`.
   
   :param `val`: the value to test;
   :param `valMin`: the minimum range value;
   :param `valMax`: the maximum range value.


.. function:: LightenColour(crColour, byIncreaseVal)

   Lightens a colour.
   
   :param `crColour`: a valid :class:`wx.Colour` object;
   :param `byIncreaseVal`: an integer specifying the amount for which the input
    colour should be brightened.


