Package wx :: Package lib :: Package agw :: Module floatspin

[frames | no frames]

## Module wx.lib.agw.floatspin

Description:

FloatSpin implements a floating point spinctrl. It is built using a custom wx.PyControl, composed by a wx.TextCtrl and a wx.SpinButton. In order to correctly handle floating points numbers without rounding errors or non-exact floating point representations, FloatSpin uses the great FixedPoint class from Tim Peters.

What you can do:

- Set the number of representative digits for your floating point numbers;
- Set the floating point format (%f, %F, %e, %E, %g, %G);
- Set the increment of every EVT_FLOATSPIN event;
- Set minimum, maximum values for FloatSpin as well as its range;
- Change font and colour for the underline wx.TextCtrl.

Events Catched:

FloatSpin catched 3 different types of events:

1. Spin events: events generated by spinning up/down the spinbutton;
2. Char events: playing with up/down arrows of the keyboard increase/decrease the value of FloatSpin;
3. Mouse wheel event: using the wheel will change the value of FloatSpin.

In addition, there are some other functionalities:

It remembers the initial value as a default value, call SetToDefaultValue, or press <ESC> to return to it

shift + arrow = 2 * increment (or shift + mouse wheel) ctrl + arrow = 10 * increment (or ctrl + mouse wheel) alt + arrow = 100 * increment (or alt + mouse wheel)

Combinations of shift, ctrl, alt increment the FloatSpin value by the product of the factors;

pgup & pgdn = 10 * increment * the product of the shift, ctrl, alt factors;

<space> sets the control's value to it's last valid State.

Usage:

FloatSpin construction can be summarized as Follows:

FloatSpin.__init__(self, parent, id, pos=wx.defaultposition,
  size=wx.defaultsize, style=0, value=0.0, min_val=None, max_val=None, increment=1.0, digits=-1, extrastyle=FS_LEFT, name="FloatSpin")

Where:

- value: is the current value for FloatSpin;
- min_val: the minimum value, not used if none
- max_val: the maximum value, not used if none
- increment: the increment for every evt_floatspin events;
- digits: number of representative digits for your floating point numbers;
- extrastyle: one of the following: a) FS_LEFT: align underline wx.TextCtrl left; b) FS_RIGHT: align underline wx.TextCtrl right; c) FS_CENTRE: align underline wx.TextCtrl center; plus the possibility to use FS_READONLY, that makes the underline wx.TextCtrl read-only (no edits possible).

See FloatSpin __init__() method for the definition of non standard (non wxPython) parameters.

FloatSpin control is freeware and distributed under the wxPython license.

Latest revision: Andrea Gavana @ 15 Oct 2008, 10.00 GMT Version 0.5

Modifications to allow min_val or max_val to be None done by:

> James Bigler sci institute, university of utah march 14, 2007

Note that the changes i made will break backward compatibility, because i changed the contructor's parameters from min/max to min_val/max_val to be consistent with the other functions and to eliminate any potential confusion with the built in min and max functions.

You specify open ranges like this (you can equally do this in the constructor):

[1,] => SetRange(min_val=1, max_val=None) [,0] => SetRange(min_val=None, max_val=0)

or no range:

[,] => Setrange(min_val=None, max_val=None)

Classes
`FixedPoint` |
`FloatSpin` |
`FloatSpinEvent` | This event will be sent when a EVT_FLOATSPIN event is mapped in the parent.
`FloatTextCtrl` |

Generated by Epydoc 2.1.20050511.rpd on Mon Feb 16 12:54:54 2009 | http://epydoc.sf.net