PyDMSlider

class pydm.widgets.slider.PyDMSlider(parent=None, init_channel=None)[source]

Bases: QFrame, TextFormatter, PyDMWritableWidget

A QSlider with support for Channels and more from PyDM.

Parameters:
  • parent (QWidget) – The parent widget for the Label

  • init_channel (str, optional) – The channel to be used by the widget.

apply_and_close_menu()[source]

Method for the ‘ok’ button in the slider parameters menu.

apply_step_size_menu_changes()[source]

Method which attempts to set the user imputed data from the slider parameters menu.

connection_changed(connected)[source]

Callback invoked when the connection state of the Channel is changed. This callback acts on the connection state to enable/disable the widget and also trigger the change on alarm severity to ALARM_DISCONNECTED.

Parameters:

connected (int) – When this value is 0 the channel is disconnected, 1 otherwise.

ctrl_limit_changed(which, new_limit)[source]

Callback invoked when the Channel receives new control limit values.

Parameters:
  • which (str) – Which control limit was changed. “UPPER” or “LOWER”

  • new_limit (float) – New value for the control limit

find_closest_slider_position_to_value(val)[source]

Find and returns the index for the closest position on the slider for a given value.

Parameters:

val (float) –

Return type:

int

float_range()[source]

Creates a range of numbers from the min, max and given step size.

Returns:

new_indexes

Return type:

list of floats

hasTracking()[source]

An alternative function to get the tracking property, to match what Qt provides for QSlider.

ignoreMouseWheel

If true, the mouse wheel will not change the value of the slider. This is useful if you want to put sliders inside a scroll view, and don’t want to accidentally change the slider as you are scrolling.

init_for_designer()[source]

Method called after the constructor to tweak configurations for when using the widget with the Qt Designer

internal_slider_moved(val)[source]

Method invoked when the slider is moved.

Parameters:

val (float) –

internal_slider_pressed()[source]

Method invoked when the slider is pressed

internal_slider_released()[source]

Method invoked when the slider is released

internal_slider_value_changed(val)[source]

Method invoked when a new value is selected on the slider. This will cause the new value to be emitted to the signal unless mute_internal_slider_changes is True.

Parameters:

val (int) –

property maximum

The current value being used for the upper limit

Return type:

float

property minimum

The current value being used for the lower limit

Return type:

float

mousePressEvent(mouse_event)[source]

Method to open slider parameters menu with a right click.

Parameters:

mouse_event (mousePressEvent) –

num_steps

The number of steps on the slider

Return type:

int

orientation

The slider orientation (Horizontal or Vertical)

Returns:

Qt.Horizontal or Qt.Vertical

Return type:

int

reset_slider_limits()[source]

Reset the limits and adjust the labels properly for the slider.

setTracking(checked)[source]

An alternative function to set the tracking property, to match what Qt provides for QSlider.

set_enable_state()[source]

Determines Whether or not the widget must be enabled or not depending on the write access, connection state and presence of limits information

set_slider_to_closest_value(val)[source]

Set the value for the slider according to a given value.

Parameters:

val (float) –

setup_widgets_for_orientation(new_orientation)[source]

Reconstruct the widget given the orientation.

Parameters:

new_orientation (int) – Qt.Horizontal or Qt.Vertical

showLimitLabels

Whether or not the high and low limits should be displayed on the slider.

Return type:

bool

showValueLabel

Whether or not the current value should be displayed on the slider.

Return type:

bool

slider_parameters_menu(position_of_click)[source]
Method that builds a menu to modify a set of Slider Parameters:
  1. value

  2. new step size (float or channel) and scale factor for step size

  3. precision or if precision is defined from a channel

  4. format of numbers on slider (min, max, value) - float or exp

step_size

The number of steps on the slider

Return type:

int

step_size_changed(new_val)[source]

PyQT Slot for changes on the Value of the Channel This slot sends the value to the step_size setter.

Parameters:

new_val (int, float) –

tickPosition

Where to draw tick marks for the slider.

Return type:

QSlider.TickPosition

tracking

If tracking is enabled (the default), the slider emits new values while the slider is being dragged. If tracking is disabled, it will only emit new values when the user releases the slider. Tracking can cause PyDM to rapidly send new values to the channel. If you are using the slider to control physical hardware, consider whether the device you want to control can handle large amounts of changes in a short timespan.

update_format_string()[source]

Reconstruct the format string to be used when representing the output value.

Returns:

format_string – The format string to be used including or not the precision and unit

Return type:

str

update_labels(exp=False)[source]

Update the limits and value labels with the correct values.

userDefinedLimits

Whether or not to use limits defined by the user and not from the channel

Return type:

bool

userMaximum

Upper user defined limit value

Return type:

float

userMinimum

Lower user defined limit value

Return type:

float

value_changed(new_val)[source]

Callback invoked when the Channel value is changed.

Parameters:

new_val (int or float) – The new value from the channel.

wheelEvent(e)[source]

Method to specifically ignore mouse wheel events.

write_access_changed(new_write_access)[source]

Callback invoked when the Channel has new write access value. This callback calls check_enable_state so it can act on the widget enabling or disabling it accordingly

Parameters:

new_write_access (bool) – True if write operations to the channel are allowed.

Note

See QFrame Documentation for all inherited properties and methods.