PyDMPushButton

class pydm.widgets.pushbutton.PyDMPushButton(parent=None, label=None, icon=None, pressValue=None, releaseValue=None, relative=False, init_channel=None)[source]

Bases: QPushButton, PyDMWritableWidget

Basic PushButton to send a fixed value.

The PyDMPushButton is meant to hold a specific value, and send that value to a channel when it is clicked, much like the MessageButton does in EDM. The PyDMPushButton works in two different modes of operation, first, a fixed value can be given to the pressValue attribute, whenever the button is clicked a signal containing this value will be sent to the connected channel. This is the default behavior of the button. However, if the relativeChange is set to True, the fixed value will be added to the current value of the channel. This means that the button will increment a channel by a fixed amount with every click, a consistent relative move

Parameters:
  • parent (QObject, optional) – Parent of PyDMPushButton

  • label (str, optional) – String to place on button

  • icon (QIcon, optional) – An Icon to display on the PyDMPushButton

  • pressValue (int, float, str) – Value to be sent when the button is clicked

  • relative (bool, optional) – Choice to have the button perform a relative put, instead of always setting to an absolute value

  • init_channel (str, optional) – ID of channel to manipulate

PyDMIcon

Name of icon to be set from Qt provided standard icons or from the fontawesome icon-set. See “enum QStyle::StandardPixmap” in Qt’s QStyle documentation for full list of usable standard icons. See https://fontawesome.com/icons?d=gallery for list of usable fontawesome icons.

Return type:

str

PyDMIconColor

The color of the icon (color is only applied if using icon from the “Font Awesome” set) :rtype: QColor

confirmMessage

Message to be displayed at the Confirmation dialog.

Return type:

str

confirm_dialog(is_release=False)[source]

Show the confirmation dialog with the proper message in case `showConfirmMessage` is True.

Returns:

True if the message was confirmed or if `showCofirmMessage` is False.

Return type:

bool

password

Password to be encrypted using SHA256.

Warning

To avoid issues exposing the password this method always returns an empty string.

Return type:

str

passwordProtected

Whether or not this button is password protected.

Return type:

bool

pressValue

This property holds the value to send back through the channel.

The type of this value does not matter because it is automatically converted to match the prexisting value type of the channel. However, the sign of the value matters for both the fixed and relative modes.

Return type:

str

protectedPassword

The encrypted password.

Return type:

str

relativeChange

The mode of operation of the PyDMPushButton.

If set to True, the pressValue will be added to the current value of the channel. If False, the pressValue will be sent without any operation.

This flag will be ignored if the connected channel sends a str type value to receiveValue(). This is designed to eliminate the undesirable behavior of concatenating strings as opposed to doing mathematical addition.

Return type:

bool

releaseValue

This property holds the value to send back through the channel.

The type of this value does not matter because it is automatically converted to match the prexisting value type of the channel. However, the sign of the value matters for both the fixed and relative modes.

Return type:

str

sendReleaseValue()[source]

Send new release value to the channel.

This function interprets the settings of the PyDMPushButton and sends the appropriate value out through the send_value_signal.

Returns:

  • None if any of the following condition is False

    1. There’s no new value (releaseValue) for the widget

    2. There’s no initial or current value for the widget

    3. The confirmation dialog returns No as the user’s answer to the dialog

    4. The password validation dialog returns a validation error

    5. writeWhenRelease is False

  • Otherwise, return the value sent to the channel

    1. The value sent to the channel is the same as the pressValue if the existing channel type is a str, or the relative flag is False

    2. The value sent to the channel is the sum of the existing value and the pressValue if the relative flag is True, and the channel type is not a str

sendValue()[source]

Send a new value to the channel.

This function interprets the settings of the PyDMPushButton and sends the appropriate value out through the send_value_signal.

Returns:

  • None if any of the following condition is False

    1. There’s no new value (pressValue) for the widget

    2. There’s no initial or current value for the widget

    3. The confirmation dialog returns No as the user’s answer to the dialog

    4. The password validation dialog returns a validation error

  • Otherwise, return the value sent to the channel

    1. The value sent to the channel is the same as the pressValue if the existing channel type is a str, or the relative flag is False

    2. The value sent to the channel is the sum of the existing value and the pressValue if the relative flag is True, and the channel type is not a str

showConfirmDialog

Whether or not to display a confirmation dialog.

Return type:

bool

updatePressValue(value)[source]

Update the pressValue of a function by passing a signal to the PyDMPushButton.

This is useful to dynamically change the pressValue of the button during runtime. This enables the applied value to be linked to the state of a different widget, say a QLineEdit or QSlider

Parameters:

value (int, float or str) –

updateReleaseValue(value)[source]

Update the releaseValue of a function by passing a signal to the PyDMPushButton.

This is useful to dynamically change the releaseValue of the button during runtime. This enables the applied value to be linked to the state of a different widget, say a QLineEdit or QSlider

Parameters:

value (int, float or str) –

validate_password()[source]

If the widget is `passwordProtected`, this method will propmt the user for the correct password.

Returns:

True in case the password was correct of if the widget is not password protected.

Return type:

bool

writeWhenRelease

Whether or not to write releaseValue on release

Return type:

bool

Note

See QPushButton Documentation for all inherited properties and methods.