fsleyes_widgets.floatspin
¶
This module provides the FloatSpinCtrl
class, a spin control for
modifying a floating point value.
-
class
fsleyes_widgets.floatspin.
FloatSpinCtrl
(parent, minValue=None, maxValue=None, increment=None, value=None, style=None, width=None, evDelta=None)¶ Bases:
wx._core.Panel
A
FloatSpinCtrl
is awx.Panel
which contains awx.TextCtrl
and awx.SpinButton
, allowing the user to modify a floating point (or integer) value.The
FloatSpinCtrl
is an alternative towx.SpinCtrl
,wx.SpinCtrlDouble
, andwx.lib.agw.floatspin.FloatSpin
.wx.SpinCtrlDouble
: Under Linux/GTK, this widget does not allow- the user to enter values that are not a multiple of the increment.
wx.lib.agw.floatspin.FloatSpin
. Differs from thewx.SpinCtrl
API in various annoying ways, and formatting is a pain.
Create a
FloatSpinCtrl
.- The following style flags are available:
FSC_MOUSEWHEEL
If set, mouse wheel events on the control will change the value. FSC_INTEGER
If set, the control stores an integer value, rather than a floating point value. FSC_NO_LIMIT
If set, the control will allow the user to enter values that are outside of the current minimum/maximum limits.
Parameters: - parent – The parent of this control (e.g. a
wx.Panel
). - minValue – Initial minimum value.
- maxValue – Initial maximum value.
- increment – Default increment to apply when the user changes the value via the spin button or mouse wheel.
- value – Initial value.
- style – Style flags - a combination of
FSC_MOUSEWHEEL
,FSC_INTEGER
, andFSC_NO_LIMIT
. - width – If provided, desired text control width (in characters).
- evDelta –
Minimum time between consecutive
wx.SpinButton
events. On Linux/GTK, the wx.SpinButton is badly behaved - if, while clicking on the mouse button, the user moves the mouse even a tiny bit, more than one spin event will be generated. To work around this (without having to write my ownwx.SpinButton
implementation), theevDelta
parameter allows me to throttle the maximum rate at which events received from the spin button can be processed. This is implemented in the__onSpinDown()
and__onSpinUp()
methods.This has the side effect that if the user clicks and holds on the spin button, they have to wait <delta> seconds between increments/decrements.
-
__init__
(parent, minValue=None, maxValue=None, increment=None, value=None, style=None, width=None, evDelta=None)¶ Create a
FloatSpinCtrl
.- The following style flags are available:
FSC_MOUSEWHEEL
If set, mouse wheel events on the control will change the value. FSC_INTEGER
If set, the control stores an integer value, rather than a floating point value. FSC_NO_LIMIT
If set, the control will allow the user to enter values that are outside of the current minimum/maximum limits.
Parameters: - parent – The parent of this control (e.g. a
wx.Panel
). - minValue – Initial minimum value.
- maxValue – Initial maximum value.
- increment – Default increment to apply when the user changes the value via the spin button or mouse wheel.
- value – Initial value.
- style – Style flags - a combination of
FSC_MOUSEWHEEL
,FSC_INTEGER
, andFSC_NO_LIMIT
. - width – If provided, desired text control width (in characters).
- evDelta –
Minimum time between consecutive
wx.SpinButton
events. On Linux/GTK, the wx.SpinButton is badly behaved - if, while clicking on the mouse button, the user moves the mouse even a tiny bit, more than one spin event will be generated. To work around this (without having to write my ownwx.SpinButton
implementation), theevDelta
parameter allows me to throttle the maximum rate at which events received from the spin button can be processed. This is implemented in the__onSpinDown()
and__onSpinUp()
methods.This has the side effect that if the user clicks and holds on the spin button, they have to wait <delta> seconds between increments/decrements.
-
textCtrl
¶ Returns a reference to the
TextCtrl
contained in thisFloatSpinCtrl
.
-
spinButton
¶ Returns a reference to the
SpinButton
contained in thisFloatSpinCtrl
.
-
DoGetBestClientSize
()¶ Returns the best size for this
FloatSpinCtrl
.
-
GetValue
()¶ Returns the current value.
-
GetMin
()¶ Returns the current minimum value.
-
GetMax
()¶ Returns the current maximum value.
-
GetIncrement
()¶ Returns the current inrement.
-
SetIncrement
(inc)¶ Sets the inrement.
-
GetRange
()¶ Returns the current data range, a tuple containing the
(min, max)
values.
-
SetMin
(minval)¶ Sets the minimum value.
-
SetMax
(maxval)¶ Sets the maximum value.
-
SetRange
(minval, maxval)¶ Sets the minimum and maximum values.
-
SetValue
(newValue)¶ Sets the value.
:returns
True
if the value was changed,False
otherwise.
-
_FloatSpinCtrl__onDoubleClick
(ev)¶ Called when the user double clicks in the
TextCtrl
. Selects the entire contents of theTextCtrl
.
-
_FloatSpinCtrl__onKeyDown
(ev)¶ Called on
wx.EVT_KEY_DOWN
events. If the user pushes the up or down arrow keys, the value is changed (using the__onSpinUp()
and__onSpinDown()
methods).
-
_FloatSpinCtrl__onKillFocus
(ev)¶ Called when the text field of this
FloatSpinCtrl
loses focus. Generates anEVT_FLOATSPIN
event.
-
_FloatSpinCtrl__onMouseWheel
(ev)¶ If the
FSC_MOUSEWHEEL
style flag is set, this method is called on mouse wheel events.Calls
__onSpinUp()
on an upwards rotation, and__onSpinDown()
on a downwards rotation.
-
_FloatSpinCtrl__onSpinDown
(ev=None)¶ Called when the down button on the
wx.SpinButton
is pushed.Decrements the value by the current increment and generates a
FloatSpinEvent
.
-
_FloatSpinCtrl__onSpinUp
(ev=None)¶ Called when the up button on the
wx.SpinButton
is pushed.Increments the value by the current increment and generates a
FloatSpinEvent
.
-
_FloatSpinCtrl__onText
(ev)¶ Called when the user changes the value via the text control.
This method is called when the enter key is pressed.
If the entered value is a valid number, a
wx.EVT_TEXT_ENTER
event is generated. This event will have a boolean attribute,changed
, which isTrue
if the value that was stored was different to that entered by the user (e.g. if it was clamped to the min/max bounds).If the value was changed from its previous value, a
FloatSpinEvent
is also generated.
-
_FloatSpinCtrl__realToSpin
(value)¶ Converts the given value from real space to spin button space.
-
__module__
= 'fsleyes_widgets.floatspin'¶
-
fsleyes_widgets.floatspin.
EVT_FLOATSPIN
= <wx.core.PyEventBinder object>¶ Identifier for the
FloatSpinEvent
event.
-
fsleyes_widgets.floatspin.
FloatSpinEvent
¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event
-
fsleyes_widgets.floatspin.
FSC_MOUSEWHEEL
= 1¶ If set, mouse wheel events on the control will change the value.
-
fsleyes_widgets.floatspin.
FSC_INTEGER
= 2¶ If set, the control stores an integer value, rather than a floating point value.
-
fsleyes_widgets.floatspin.
FSC_NO_LIMIT
= 4¶ If set, the control will allow the user to enter values that are outside of the current minimum/maximum limits.