AGW Logo

agw_title knobctrl

KnobCtrl lets the user select a numerical value by rotating it.


description Description

KnobCtrl lets the user select a numerical value by rotating it. It works like a scrollbar: just set the ticks range property and read the value property in the associated EVT_KC_ANGLE_CHANGING/EVT_KC_ANGLE_CHANGED events. Simple but effective.

It can be easily used if you want to simulate the volume knob of a music player or similar functionalities.


usage Usage

Usage example:

import wx
import wx.lib.agw.knobctrl as KC

class MyFrame(wx.Frame):

    def __init__(self, parent):

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

        panel = wx.Panel(self)

        knob1 = KC.KnobCtrl(panel, -1, size=(100, 100))
        knob2 = KC.KnobCtrl(panel, -1, size=(100, 100))

        knob1.SetTags(range(0, 151, 10))
        knob1.SetAngularRange(-45, 225)
        knob1.SetValue(45)

        knob2.SetTags(range(0, 151, 10))
        knob2.SetAngularRange(0, 270)
        knob2.SetValue(100)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(knob1, 0, wx.EXPAND|wx.ALL, 20)
        main_sizer.Add(knob2, 0, wx.EXPAND|wx.ALL, 20)

        panel.SetSizer(main_sizer)
        main_sizer.Layout()


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


events Events

KnobCtrl implements two events that can be intercepted by the user:

  • EVT_KC_ANGLE_CHANGING;
  • EVT_KC_ANGLE_CHANGED.

The first one can be “vetoed” by eliminating the event.Skip() at the end of the event handler.


platforms Supported Platforms

KnobCtrl has been tested on the following platforms:
  • Windows (Windows XP);
  • Linux Ubuntu (Dapper 6.06)

styles Window Styles

This class supports the following window styles:


Window styles for knobctrl
Window Styles Hex Value Description
KC_BUFFERED_DC 0x1 Flag to use double buffering (recommendeded = 1).

events Events Processing

This class processes the following events:


Events processing for knobctrl
Event Name Description
EVT_KC_ANGLE_CHANGED Notify the client that the knob has changed its value.
EVT_KC_ANGLE_CHANGING Notify the client that the knob is changing its value.

license License And Version

KnobCtrl 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: knobctrl

Inheritance diagram of knobctrl.BufferedWindow, knobctrl.KnobCtrl, knobctrl.KnobCtrlEvent


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.

knobctrl

Revision Graph For knobctrl


2to3 Python 3 Issues (via 2to3)

No issues have been detected by 2to3.py.