Skip to content

BUG: stop designer from setting line-edits in ui file to be readOnly when PYDM_DESIGNER_ONLINE enabled #1253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions pydm/widgets/line_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from qtpy.QtCore import Property, Qt
from qtpy.QtGui import QFocusEvent
from .base import PyDMWritableWidget, TextFormatter, str_types, PostParentClassInitSetup
from pydm import utilities
from pydm import utilities, config
from .display_format import DisplayFormat, parse_value_for_display
from pydm.utilities import ACTIVE_QT_WRAPPER, QtWrapperTypes
from pydm.utilities import ACTIVE_QT_WRAPPER, QtWrapperTypes, is_qt_designer

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -162,15 +162,29 @@ def send_value(self):

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

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

def unit_changed(self, new_unit):
"""
Expand Down
Loading