Version 1 (modified by flip, 10 years ago) (diff)


The vespa.common.wx Library

vespa.common.wx is a library that, as of this writing, contains some utilities and two custom controls for use in Analysis. "Custom" control is a bit of a misnomer as only one of them is really custom. They are the floatspin control and the floatspin_multiplier control. They're explained below.


The floatspin control resembles a standard spin control, but it accepts floating point input. (The standard control accepts only integer input.) It was added to wxPython in version along with the rest of wx.lib.agw; it is not in or any earlier versions.

Ideally we would use the version of the control in wx.lib.agw if it was available and fall back on a local version if not. Code like this would work:

    import wx.lib.agw.floatspin as floatspin
except ImportError:
    import vespa.common.wx.widgets.floatspin.floatspin as floatspin

Unfortunately the standard library version contains a couple of bugs, one of which was patched in wxPython rev 62685 and the other of which was patched in wxPython rev 62920.

Our local version of the code contains these patches. If and when a version of wxPython is released that contains both patches (probably, we can use the library version with code like this:

if (wx.MAJOR_VERSION >= 2) and \
   (wx.MINOR_VERSION >= 9):
    import wx.lib.agw.floatspin as floatspin
    import vespa.common.wx.widgets.floatspin.floatspin as floatspin


This control subclass floatspin and is therefore mostly the same, but it de/increments the value by a percentage of the value rather than by a consistent increment. It has one additional attribute called multiplier which defaults to 1. When set to e.g. 1.25, the control will de/increment its value in jumps of 25%.