phoenix_title wx.lib.agw.knobctrl

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

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 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.App(0)

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

app.MainLoop()

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.

Supported Platforms

KnobCtrl has been tested on the following platforms:
  • Windows (Windows XP);

  • Linux Ubuntu (Dapper 6.06)

Window Styles

This class supports the following window styles:

Window Styles

Hex Value

Description

KC_BUFFERED_DC

0x1

Flag to use double buffering (recommendeded = 1).

Events Processing

This class processes the following events:

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 And Version

KnobCtrl is distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 27 Dec 2012, 21.00 GMT

Version 0.4

class_summary Classes Summary

BufferedWindow

A Buffered window class.

KnobCtrl

This class can be used to simulate a knob volume control often found in

KnobCtrlEvent

Represent details of the events that the KnobCtrl object sends.