FloatSpin implements a floating point wx.SpinCtrl.
FloatSpin implements a floating point wx.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:
Usage example:
import wx
import wx.lib.agw.floatspin as FS
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "FloatSpin Demo")
panel = wx.Panel(self)
floatspin = FS.FloatSpin(panel, -1, pos=(50, 50), min_val=0, max_val=1,
increment=0.01, value=0.1, agwStyle=FS.FS_LEFT)
floatspin.SetFormat("%f")
floatspin.SetDigits(2)
# 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.
FloatSpin catches 3 different types of events:
In addition, there are some other functionalities:
This class supports the following window styles:
Window Styles | Hex Value | Description |
---|---|---|
FS_READONLY | 0x1 | Sets FloatSpin as read-only control. |
FS_LEFT | 0x2 | Horizontally align the underlying wx.TextCtrl on the left. |
FS_CENTRE | 0x4 | Horizontally align the underlying wx.TextCtrl on center. |
FS_RIGHT | 0x8 | Horizontally align the underlying wx.TextCtrl on the right. |
This class processes the following events:
Event Name | Description |
---|---|
EVT_FLOATSPIN | Emitted when the user changes the value of FloatSpin, either with the mouse or with the keyboard. |
FloatSpin control is distributed under the wxPython license.
Latest revision: Andrea Gavana @ 17 Aug 2011, 15.00 GMT
Version 0.9
Modifications to allow min_val or max_val to be None done by:
James Bigler, SCI Institute, University of Utah, March 14, 2007
Note
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):
SetRange(min_val=1, max_val=None) # [1, ]
SetRange(min_val=None, max_val=0) # [ , 0]
or no range:
SetRange(min_val=None, max_val=None) # [ , ]
Module author: Andrea Gavana <andrea.gavana@gmail.com>
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.
Revision Graph For floatspin