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.

calc_step_size()[source]

Given max, min, and num steps calculate step size

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.

create_slider_positions_to_value_map()[source]

Wrapper around step_size_to_slider_positions_value_map to ensure the func is only called after a step_size has been set

Returns:

positions_to_value_map – list with all possible allowed slider readback values

Return type:

list

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.

Return type:

int

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

init_step_size_channel(pv_address: str, slot: callable)[source]

Connects instance attribute self.step_size_channel_pv to a PyDMChannel

Parameters:
  • pv_address (str) – Channel name of PV that connection will be established too.

  • slot (callable) – callback function to invoke when channel value changes.

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) –

step_size_channel

String to connect to pydm channel after initialization

step_size_to_slider_positions_value_map()[source]

Given a value increment by step size and record allowed values until self.maximum, Repeat with decrementer until self.minimum, take results and create a linear array of allowed values where the length of the array is the number of slider positions. and the slider position i has value array[i].

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

property value

Channel readback value used to determine slider position and generate a slider positions to value map

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.