PyDMLineEdit
- class pydm.widgets.line_edit.PyDMLineEdit(parent=None, init_channel=None)[source]
Bases:
QLineEdit
,TextFormatter
,PyDMWritableWidget
,DisplayFormat
A QLineEdit (writable text field) with support for Channels and more from PyDM. This widget offers an unit conversion menu when users Right Click into it.
- Parameters:
parent (QWidget) – The parent widget for the Label
init_channel (str, optional) – The channel to be used by the widget.
- apply_conversion(unit)[source]
Convert the current unit to a different one
This function will attempt to find a scalar to convert the current unit type to the desired one and reset the display with the new conversion.
- Parameters:
unit (str) – String name of desired units
- create_unit_options()[source]
Create the menu for displaying possible unit values
The menu is filled with possible unit conversions based on the current PyDMLineEdit. If either the unit is not found in the by the
utilities.find_unit_options()
function, or, theshowUnits
attribute is set to False, the menu will tell the user that there are no available conversions
- focusInEvent(event: QFocusEvent) None [source]
Checks to see if the line edit has actually received a value before assigning active window or tab focus to it. PyQt will automatically give tab focus to the first tab-enabled widget it can on display load. But for this widget this behavior can lead to a race condition where if the widget is given focus before the PV has been connected long enough to receive a value, then the widget never loads the initial text from the PV.
- focusOutEvent(event)[source]
Overwrites the function called when a user leaves a PyDMLineEdit without pressing return. Resets the value of the text field to the current channel value.
- send_value()[source]
Emit a
send_value_signal
to update channel value.The text is cleaned of all units, user-formatting and scale values before being sent back to the channel. This function is attached the ReturnPressed signal of the PyDMLineEdit
- set_display()[source]
Set the text display of the PyDMLineEdit.
The original value given by the PV is converted to a text entry based on the current settings for scale value, precision, a user-defined format, and the current units. If the user is currently entering a value in the PyDMLineEdit the text will not be changed.
- unit_changed(new_unit)[source]
Accept a unit to display with a channel’s value
The unit may or may not be displayed based on the
showUnits
attribute. Receiving a new value for the unit causes the display to reset.
- value_changed(new_val)[source]
Receive and update the PyDMLineEdit for a new channel value
The actual value of the input is saved as well as the type received. This also resets the PyDMLineEdit display text using
set_display()
- Parameters:
value (str, float or int) – The new value of the channel
Fetch the Widget specific context menu which will be populated with additional tools by assemble_tools_menu.
- Returns:
If the return of this method is None a new QMenu will be created by assemble_tools_menu.
- Return type:
QMenu or None
Note
See QLineEdit Documentation for all inherited properties and methods.