fsleyes_widgets.floatspin

This module provides the FloatSpinCtrl class, a spin control for modifying a floating point value.

class fsleyes_widgets.floatspin.SpinButton(parent, style=4, upLabel='+', downLabel='−')[source]

Bases: Control

Replacement for wx.SpinButton.

A control which contains up and down buttons, and which emits events EVT_SPIN_UP and EVT_SPIN_DOWN events when they are pressed.

This is used by the FloatSpinCtrl instead of the wx.SpinButton because:

  • The``wx.SpinButton`` internally stores the current value as a signed 32 bit integer. It is much easier for the FloatSpinCtrl to keep track of its own floating point value and limits.

  • The FloatSpinCtrl displays its own text area, but on some GTK versions, the wx.SpinButton displays a text area, I think due to some latent bugs in wxwidgets - see e.g. https://github.com/wxWidgets/wxWidgets/issues/17847

Create a SpinButton.

Parameters:
  • parentwx parent object

  • style – Button orientation - either wx.HORIZONTAL or wx.VERTICAL

  • upLabel – Up button label

  • downLabel – Down button label

property upButton

Returns a reference to the up button.

property downButton

Returns a reference to the down button.

EnableUp(enable)[source]

Enable/disable the up button.

DisableUp()[source]

Disable the up button.

EnableDown(enable)[source]

Enable/disable the down button.

DisableDown()[source]

Disable the down button.

fsleyes_widgets.floatspin.EVT_SPIN_UP = <wx.core.PyEventBinder object>

Identifier for the SpinUpEvent event.

fsleyes_widgets.floatspin.EVT_SPIN_DOWN = <wx.core.PyEventBinder object>

Identifier for the SpinDownEvent event.

fsleyes_widgets.floatspin.SpinUpEvent

Event emitted when by a SpinButton when its up button is pushed.

fsleyes_widgets.floatspin.SpinDownEvent

Event emitted when by a SpinButton when its down button is pushed.

class fsleyes_widgets.floatspin.FloatSpinCtrl(parent, minValue=None, maxValue=None, increment=None, value=None, style=None, width=None, evDelta=None, precision=None)[source]

Bases: Control

A FloatSpinCtrl is a wx.Control which contains a wx.TextCtrl and a wx.SpinButton, allowing the user to modify a floating point (or integer) value.

The FloatSpinCtrl is an alternative to wx.SpinCtrl, wx.SpinCtrlDouble, and wx.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 the wx.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, and FSC_NO_LIMIT.

  • width – If provided, desired text control width (in characters).

  • evDelta

    Deprecated, has no effect.

    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.

  • precision – The desired precision to the right of the decimal value. Ignored if the FSC_INTEGER style is active.

property textCtrl

Returns a reference to the TextCtrl contained in this FloatSpinCtrl.

property spinButton

Returns a reference to the SpinButton contained in this FloatSpinCtrl.

DoGetBestClientSize()[source]

Returns the best size for this FloatSpinCtrl.

GetValue()[source]

Returns the current value.

GetMin()[source]

Returns the current minimum value.

GetMax()[source]

Returns the current maximum value.

GetIncrement()[source]

Returns the current inrement.

SetIncrement(inc)[source]

Sets the inrement.

GetRange()[source]

Returns the current data range, a tuple containing the (min, max) values.

SetMin(minval)[source]

Sets the minimum value.

SetMax(maxval)[source]

Sets the maximum value.

SetRange(minval, maxval)[source]

Sets the minimum and maximum values.

SetValue(newValue)[source]

Sets the value.

:returns True if the value was changed, False otherwise.

fsleyes_widgets.floatspin.EVT_FLOATSPIN = <wx.core.PyEventBinder object>

Identifier for the FloatSpinEvent event.

fsleyes_widgets.floatspin.FloatSpinEvent

Event emitted when the floating point value is changed by the user. A FloatSpinEvent has the following attributes:

  • value: The new value.

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.