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

Conversation

nstelter-slac
Copy link
Collaborator

@nstelter-slac nstelter-slac commented May 14, 2025

when editing a lineedit widget in designer after doing 'export PYDM_DESIGNER_ONLINE=1',
we want widgets to act as read-only so PVs are not accidentally changed
when modifying screens. this is enforced by the dataplugins themselves
and is_read_only() (set during designer setup: https://github.com/slaclab/pydm/blob/master/pydm/qtdesigner.py#L47)

but we don't want the readOnly=true status to be saved into the
ui file containing the lineedit.

to avoid this, don't let lineedit set itself to readOnly if it's
loaded in designer with live data enabled. (it will still act in a
read-only way thanks to dataplugins themselves)

@nstelter-slac nstelter-slac changed the title BUG: stop designer from setting lineedits in their ui file to be read only when PYDM_DESIGNER_ONLINE is set. BUG: stop designer from setting lineedits in their ui file to be readOnly when PYDM_DESIGNER_ONLINE is set. May 14, 2025
@nstelter-slac nstelter-slac force-pushed the readonly_ui_fix branch 2 times, most recently from 2426824 to 6130c4d Compare May 14, 2025 03:39
@nstelter-slac nstelter-slac changed the title BUG: stop designer from setting lineedits in their ui file to be readOnly when PYDM_DESIGNER_ONLINE is set. BUG: stop designer from setting line-edits in ui file to be readOnly when PYDM_DESIGNER_ONLINE enabled May 14, 2025
…when PYDM_DESIGNER_ONLINE enabled

when editing a lineedit widget in designer after doing 'export PYDM_DESIGNER_ONLINE=1',
we want widgets to act as read-only so PVs are not accidentally changed
when modifying screens. this is enforced by the dataplugins themselves
and is_read_only() (set during designer setup: https://github.com/slaclab/pydm/blob/master/pydm/qtdesigner.py#L47)

but we don't want the readOnly=true status to be saved into the
ui file containing the lineedit.

to avoid this, don't let lineedit set itself to readOnly if it's
loaded in designer with live data enabled. (it will still act in a
read-only way thanks to dataplugins themselves)
@ZLLentz
Copy link
Member

ZLLentz commented May 14, 2025

Irrespective of my suggestions/notes above, I'll run this myself and verify that I see better behavior

@ZLLentz
Copy link
Member

ZLLentz commented May 14, 2025

I'm going to stop trying to test this because I want you to test it first

@nstelter-slac
Copy link
Collaborator Author

I'm going to stop trying to test this because I want you to test it first

ok sry for that!

did do testing b4 but seems i didnt upload my latest local changes

@nstelter-slac
Copy link
Collaborator Author

nstelter-slac commented May 15, 2025

ok tested latest changes as follows:

-create a ui file with PyDMLineEdit widget, channel ca://MTEST:Float, and set readOnly to explicitly unchecked (not default unchecked), save as debug.ui
-start ./pydm_testing_ioc in a terminal
-in another terminal run export PYDM_DESIGNER_ONLINE=1
-then designer debug.ui
-change tooltip text of lineedit and saved file in designer
-open in text-editor and see debug.ui now is readOnly is True or run pydm debug.ui to see its in a readonly state

-open text-editor and manually reset debug.ui readOnly setting to False
-do the same steps above now on readonly_ui_fix branch, and see that readOnly setting in debug.ui does not get changed by designer

@ZLLentz
Copy link
Member

ZLLentz commented May 15, 2025

This does fix the bug!

But it introduces the opposite problem, in that readOnly is always set back to False after we roll through this call chain, which means after you save it again it can never be readOnly. So, users who want their PyDMLineEdit to be read-only (why??) can no longer do so if they edit in this way.

Is a read-only PyDMLineEdit something we need to support? If so, then we need a solution that preserves the user's option. If not, then maybe this code block can be much simpler (I assume it exists as-is to preserve a user's readOnly=True setting in the face of write_access=True)

@nstelter-slac
Copy link
Collaborator Author

nstelter-slac commented May 15, 2025

This does fix the bug!

But it introduces the opposite problem, in that readOnly is always set back to False after we roll through this call chain, which means after you save it again it can never be readOnly. So, users who want their PyDMLineEdit to be read-only (why??) can no longer do so if they edit in this way.

Is a read-only PyDMLineEdit something we need to support? If so, then we need a solution that preserves the user's option. If not, then maybe this code block can be much simpler (I assume it exists as-is to preserve a user's readOnly=True setting in the face of write_access=True)

ok yes i see the issue.

as for why you would want a readonly lineedit (as opposed to say a label just displaying the value), the justification from the qt docs for the setting is:

`In read-only mode, the user can still copy the text to the clipboard...'

@nstelter-slac
Copy link
Collaborator Author

nstelter-slac commented May 15, 2025

btw here's the original pr for some justification: #939

also this same issue seems to happen with the enabled setting of PyDMSlider, where we do a similar thing as the linedit https://github.com/slaclab/pydm/blob/master/pydm/widgets/slider.py#L784

@nstelter-slac
Copy link
Collaborator Author

nstelter-slac commented May 15, 2025

actually seems like this effects all widgets b/c of code in base.py , inserting enabled=False into the ui files after editing unrelated property in designer
(https://github.com/slaclab/pydm/blob/master/pydm/widgets/base.py#L1484)

but turns out it doesn't end up actually disabling other widgets at non-designer runtime, despite the ui file changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PyDMLineEdit can get saved as read-only if marked explicitly as not read-only
2 participants