Skip to content

Commit 2426824

Browse files
committed
BUG: stop designer from setting lineedits in their ui file to be readOnly when PYDM_DESIGNER_ONLINE is set
when editing a lineedit widget in designer after having done 'export PYDM_DESIGNER_ONLINE=1', we do want widgets to act as read-only so PVs are not accidently changeded when modifying screens. this is enforced by the dataplugins themselves and their is_read_only() call. but we do not want this readOnly=true status to be saved into the ui file containting the lineedit. to avoid this, don't let the lineedit set itself to readOnly if is loaded in designer with live data enabled. (it will still act in a read-only way thansk the the dataplugins themselves)
1 parent 5aaf9b9 commit 2426824

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pydm/widgets/line_edit.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .base import PyDMWritableWidget, TextFormatter, str_types, PostParentClassInitSetup
1111
from pydm import utilities
1212
from .display_format import DisplayFormat, parse_value_for_display
13-
from pydm.utilities import ACTIVE_QT_WRAPPER, QtWrapperTypes
13+
from pydm.utilities import ACTIVE_QT_WRAPPER, QtWrapperTypes, is_qt_designer
1414

1515
logger = logging.getLogger(__name__)
1616

@@ -162,14 +162,26 @@ def send_value(self):
162162

163163
def setReadOnly(self, readOnly):
164164
self._user_set_read_only = readOnly
165-
super().setReadOnly(True if self._user_set_read_only else not self._write_access)
165+
shouldSetReadOnly = True if self._user_set_read_only else (not self._write_access)
166+
# When in designer and reading in live data (DESIGNER_ONLINE), don't set and therefore save to
167+
# the ui file readOnly=True setting. While we do want widgets to act in read-only way in designer
168+
# (so don't accidentally write data during editing), this is handled in the data_plugins themselves.
169+
if is_qt_designer() and config.DESIGNER_ONLINE:
170+
shouldSetReadOnly = False
171+
super().setReadOnly(shouldSetReadOnly)
166172

167173
def write_access_changed(self, new_write_access):
168174
"""
169175
Change the PyDMLineEdit to read only if write access is denied
170176
"""
171177
super().write_access_changed(new_write_access)
172178
if not self._user_set_read_only:
179+
shouldSetReadOnly = not new_write_access
180+
# When in designer and reading in live data (DESIGNER_ONLINE), don't set and therefore save to
181+
# the ui file readOnly=True setting. While we do want widgets to act in read-only way in designer
182+
# (so don't accidentally write data during editing), this is handled in the data_plugins themselves.
183+
if is_qt_designer() and config.DESIGNER_ONLINE:
184+
shouldSetReadOnly = False
173185
super().setReadOnly(not new_write_access)
174186

175187
def unit_changed(self, new_unit):

0 commit comments

Comments
 (0)