fsleyes_widgets.rangeslider

This module provides the RangePanel and RangeSliderSpinPanel classes, both of which contain controls allowing the user to modify a range.

The RangeSliderSpinPanel is a widget which contains two RangePanel widgets - one with sliders, and one with spinboxes. All four control widgets are linked.

class fsleyes_widgets.rangeslider.RangePanel(parent, minValue=None, maxValue=None, lowValue=None, highValue=None, lowLabel=None, highLabel=None, minDistance=None, spinWidth=None, style=0)[source]

Bases: Panel

RangePanel is a widget which contains two sliders or spinboxes (either FloatSlider, or FloatSpinCtrl), allowing a range to be set.

When the user changes the low range value to a value beyond the current high value, the high value is increased such that it remains at least a minimum value above the low value. The inverse relationship is also enforced. Whenever the user chenges the low or high range values, EVT_LOW_RANGE or EVT_HIGH_RANGE events are generated respectively.

A situation may arise whereby a change to one limit will affect the other ( e.g. when enforcing a minimum distance between the values). When this occurs, an EVT_RANGE event is generated. So you may need to listen for all three types of event.

The following style flags are available:

RP_INTEGER

If set, the RangePanel stores integer values, rather than floating point.

RP_MOUSEWHEEL

If set, the user will be able to change the range values with the mouse wheel.

RP_SLIDER

If set, FloatSlider widgets will be used to control the range values.

RP_NO_LIMIT

If set, and RP_SLIDER is not set, the user will be able to enter values into the spin controls that are beyond the current minimum/maximum range values.

Create a RangePanel.

Parameters:
  • parent – The wx parent object.

  • minValue – Minimum range value.

  • maxValue – Maximum range value.

  • lowLabel – If not None, a wx.StaticText widget is placed to the left of the low widget, containing the given label.

  • highLabel – If not None, a wx.StaticText widget is placed to the left of the high widget, containing the given label.

  • lowValue – Initial low range value.

  • highValue – Initial high range value.

  • minDistance – Minimum distance to be maintained between low/high values.

  • spinWidth – Desired spin control width. See the FloatSpinCtrl class.

  • style – A combination of RP_MOUSEWHEEL, RP_INTEGER, RP_SLIDER, and RP_NO_LIMIT.

property lowWidget

Returns the low widget, either a FloatSlider or FloatSpinCtrl.

property highWidget

Returns the high widget, either a FloatSlider or FloatSpinCtrl.

GetDistance()[source]

Returns the minimum distance that is maintained between the low/high range values.

SetDistance(distance)[source]

Sets the minimum distance to be maintained between the low/high range values.

GetLow()[source]

Returns the current low range value.

GetHigh()[source]

Returns the current high range value.

SetLow(lowValue)[source]

Set the current low range value

SetHigh(highValue)[source]

Set the current high range value

GetRange()[source]

Returns a tuple containing the current (low, high) range values.

SetRange(lowValue, highValue)[source]

Sets the current (low, high) range values, making sure that they are at within the low/high limits, and least (min distance) apart.

GetLimits()[source]

Returns a tuple containing the current (minimum, maximum) range limit values.

SetLimits(minValue, maxValue)[source]

Sets the current (minimum, maximum) range limit values.

GetMin()[source]

Returns the current minimum range value.

GetMax()[source]

Returns the current maximum range value.

SetMin(minValue)[source]

Sets the current minimum range value.

SetMax(maxValue)[source]

Sets the current maximum range value.

class fsleyes_widgets.rangeslider.RangeSliderSpinPanel(parent, minValue=None, maxValue=None, lowValue=None, highValue=None, minDistance=None, lowLabel=None, highLabel=None, spinWidth=None, style=None)[source]

Bases: Panel

A wx.Panel which contains two sliders and two spinboxes.

The sliders and spinboxes are contained within two RangePanel instances respectively. One slider and spinbox pair is used to edit the low value of a range, and the other slider/spinbox used to edit the high range value. Buttons are optionally displayed on either end which display the minimum/maximum limits and, when clicked, allow the user to modify said limits.

The RangeSliderSpinPanel forwards events from the RangePanel instances when the user edits the low/high range values, and generates a RangeLimitEvent when the user edits the range limits.

The following style flags are available:

RSSP_INTEGER

If set, the RangeSliderSpinPanel stores integer values, rather than floating point.

RSSP_MOUSEWHEEL

If set, the user will be able to change the range values with the mouse wheel.

RSSP_SHOW_LIMITS

If set, the minimum/maximum range values are shown alongside the range controls.

RSSP_EDIT_LIMITS

If set, and RSSP_SHOW_LIMITS is also set, the minimum/maximum range values are shown alongside the range controls on buttons.

RSSP_NO_LIMIT

If set, the user is able to enter values into the spin controls which are outside of the current minimum/maximum.

A RangeSliderSpinPanel will look something like this:

Create a RangeSliderSpinPanel.

Parameters:
  • parent – The wx parent object.

  • minValue – Minimum low value.

  • maxValue – Maximum high value.

  • lowValue – Initial low value.

  • highValue – Initial high value.

  • minDistance – Minimum distance to maintain between low and high values.

  • lowLabel – If not None, a wx.StaticText widget is placed to the left of the low slider, containing the label.

  • highLabel – If not None, a wx.StaticText widget is placed to the left of the high slider, containing the label.

  • spinWidth – Desired spin control width. Defaults to 6. See the FloatSpinCtrl class.

  • style – A combination of RSSP_INTEGER, RSSP_MOUSEWHEEL, RSSP_SHOW_LIMITS, RSSP_EDIT_LIMITS, and RSSP_NO_LIMIT. Defaults to RSSP_SHOW_LIMITS.

property lowSlider

Returns the FloatSlider for the low range.

property highSlider

Returns the FloatSlider for the high range.

property lowSpin

Returns the FloatSpinCtrl for the low range.

property highSpin

Returns the FloatSpinCtrl for the high range.

property minButton

Returns the button to edit the lower range limit, or None if RSSP_EDIT_LIMITS is not active.

property maxButton

Returns the button to edit the upper range limit, or None if RSSP_EDIT_LIMITS is not active.

GetDistance()[source]

Returns the minimum distance between the low/high range values.

SetDistance(distance)[source]

Sets the minimum distance between the low/high range values.

GetLimits()[source]

Returns the minimum/maximum range values.

SetLimits(minValue, maxValue)[source]

Sets the minimum/maximum range values.

SetMin(minValue)[source]

Sets the minimum range value.

SetMax(maxValue)[source]

Sets the maximum range value.

GetMin()[source]

Returns the minimum range value.

GetMax()[source]

Returns the maximum range value.

GetLow()[source]

Returns the current low range value.

GetHigh()[source]

Returns the current high range value.

SetLow(lowValue)[source]

Sets the current low range value.

SetHigh(highValue)[source]

Sets the current high range value.

GetRange()[source]

Return the current (low, high) range values.

SetRange(lowValue, highValue)[source]

Set the current low and high range values.

fsleyes_widgets.rangeslider.RP_INTEGER = 1

If set, the RangePanel stores integer values, rather than floating point.

fsleyes_widgets.rangeslider.RP_MOUSEWHEEL = 2

If set, the user will be able to change the range values with the mouse wheel.

fsleyes_widgets.rangeslider.RP_SLIDER = 4

If set, FloatSlider widgets will be used to control the range values. If not set, FloatSpinCtrl widgets are used.

fsleyes_widgets.rangeslider.RP_NO_LIMIT = 8

If set, and RP_SLIDER is not set, the user will be able to enter values into the spin controls that are beyond the current minimum/maximum range values.

fsleyes_widgets.rangeslider.RSSP_INTEGER = 1

If set, the RangeSliderSpinPanel stores integer values, rather than floating point.

fsleyes_widgets.rangeslider.RSSP_MOUSEWHEEL = 2

If set, the user will be able to change the range values with the mouse wheel.

fsleyes_widgets.rangeslider.RSSP_SHOW_LIMITS = 4

If set, the minimum/maximum range values are shown alongside the range controls.

fsleyes_widgets.rangeslider.RSSP_EDIT_LIMITS = 8

If set, and RSSP_SHOW_LIMITS is also set, the minimum/maximum range values are shown alongside the range controls on buttons. When the presses a button, a dialog is displayed allowing them to change the range limits.

fsleyes_widgets.rangeslider.RSSP_NO_LIMIT = 16

If set, the user is able to enter values into the spin controls which are outside of the current minimum/maximum.

fsleyes_widgets.rangeslider.EVT_RANGE = <wx.core.PyEventBinder object>

Identifier for the RangeEvent.

fsleyes_widgets.rangeslider.EVT_LOW_RANGE = <wx.core.PyEventBinder object>

Identifier for the LowRangeEvent.

fsleyes_widgets.rangeslider.EVT_HIGH_RANGE = <wx.core.PyEventBinder object>

Identifier for the HighRangeEvent.

fsleyes_widgets.rangeslider.EVT_RANGE_LIMIT = <wx.core.PyEventBinder object>

Identifier for the RangeLimitEvent.

fsleyes_widgets.rangeslider.RangeEvent

Event emitted by RangePanel and RangeSliderSpinPanel objects when either of their low or high values change. Contains two attributes, low and high, containing the new low/high range values.

fsleyes_widgets.rangeslider.LowRangeEvent

Event emitted by RangePanel and RangeSliderSpinPanel objects when their low value changes. Contains one attributes, low, containing the new low range value.

fsleyes_widgets.rangeslider.HighRangeEvent

Event emitted by RangePanel and RangeSliderSpinPanel objects when their high value changes. Contains one attributes, high, containing the new high range value.

fsleyes_widgets.rangeslider.RangeLimitEvent

Event emitted by RangeSliderSpinPanel objects when the user modifies the range limits. Contains two attributes, min and max, containing the new minimum/maximum range limits.