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.

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

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


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.


unit (str) – String name of desired units


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, the showUnits 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.


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.


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

setReadOnly(self, a0: bool)[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.


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.


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


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.


If the return of this method is None a new QMenu will be created by assemble_tools_menu.

Return type:

QMenu or None


Change the PyDMLineEdit to read only if write access is denied


See QLineEdit Documentation for all inherited properties and methods.