AGW Logo

agw_title peakmeter

PeakMeterCtrl mimics the behaviour of equalizers that are usually found in stereos and MP3 players.


description Description

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

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:`~peakmeter.PeakMeterCtrl`.

        :param `event`: a `wx.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.PySimpleApp()

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

app.MainLoop()

This code snippet can be downloaded, see this example script.

Note

Some of the AGW snippets of code in the documentation use images and external files (to create bitmaps or access external data). As these files are not provided in these snippets, you should make the approriate modifications to the code to actually run it.


platforms Supported Platforms

PeakMeterCtrl has been tested on the following platforms:
  • Windows (Windows XP).

styles Window Styles

This class supports the following window styles:


Window styles for peakmeter
Window Styles Hex Value Description
PM_HORIZONTAL 0x0 Shows horizontal bands in PeakMeterCtrl.
PM_VERTICAL 0x1 Shows vertical bands in PeakMeterCtrl.

events Events Processing

No custom events are available for this class.


license License And Version

PeakMeterCtrl is distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 17 Aug 2011, 15.00 GMT

Version 0.3

Module author: Andrea Gavana <andrea.gavana@gmail.com>


hierarchy Inheritance Diagram

Inheritance diagram for module: peakmeter

Inheritance diagram of peakmeter.PeakMeterCtrl, peakmeter.PeakMeterData


svn_main SVN Revisions

A graphical representation of the SVN commits in the last year.

Click on any date in the picture to jump to that particular revision page, containing information about committers, log messages and SVN diffs.

peakmeter

Revision Graph For peakmeter


2to3 Python 3 Issues (via 2to3)

No issues have been detected by 2to3.py.