You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm designing a form with some related display buttons. I tried including a couple of macros (as the related forms are supposed to be generic). I did this through the Basic Settings Editor to make sure I didn't mess with the internal representation, and I managed to save macros, but when trying to open the Settings Editor again I was greeted with:
Failed to parse macro string: ['{"top": "FooBar"}']
Traceback (most recent call last):
File "/home/software/venv/3.9.6/sysco/lib/python3.9/site-packages/pydm/utilities/macro.py", line 63, in parse_macro_string
macros = json.loads(macro_string)
File "/home/software/.pyenv/versions/3.9.6/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/home/software/.pyenv/versions/3.9.6/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/software/.pyenv/versions/3.9.6/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/software/venv/3.9.6/sysco/lib/python3.9/site-packages/pydm/widgets/designer_settings.py", line 261, in set_value_from_widget
macros = parse_macro_string(value or "")
File "/home/software/venv/3.9.6/sysco/lib/python3.9/site-packages/pydm/utilities/macro.py", line 67, in parse_macro_string
raise ValueError("Could not parse macro argument as JSON.")
ValueError: Could not parse macro argument as JSON.
This works for PyDMEmbeddedDisplay though.
The main difference I see here is that PyDMEmbeddedDisplay stores the macros as a dictionary encoded as simple JSON string, where PyDMRelatedDisplayButton stores them as a list of strings. When restoring the macros, there's no problem with the simple string, but the code chokes on the list of strings.
Now, I'm not sure why the difference in storage choices, because there seems to be no good reason for PyDMRelatedDisplayButton to keep a list where a simple string would do, but you might have some insight that is escaping me :-)
Steps to Reproduce
Create an empty form
Add a PyDMRelatedDisplayButton
Double click on it to open the Basic Settings Editor
Add a macro
Save the settings and close the Editor
Reopen the Settings Editor form
Possible Solution
Change the storage choice for PyDMRelatedDisplayButton? It seems like using a simple string works fine for PyDMEmbeddedDisplay
My Platform
Happened on Linux, Python 3.9, latest stable PyDM (1.18.2)
The text was updated successfully, but these errors were encountered:
Thank you for bringing this up! The reason macros are stored differently from the embedded display is that a related display button can have multiple files assigned to it. So for example a single button can have say four displays added to it, which the user can choose from when clicking the button at run time. And in this case the first macro string in the list would go to the first display, the second to the second, and so on. It's a way to be able to send a different set of macros to each display in case just having the same set shared among each display on the button would cause conflicts.
Haven't taken a look into the code yet, but I think we'll probably just need to update the basic settings editor to handle this case.
It the mean time, assigning macros using the Property Editor in the right panel should work, although not as nice of an interface.
I'm designing a form with some related display buttons. I tried including a couple of macros (as the related forms are supposed to be generic). I did this through the Basic Settings Editor to make sure I didn't mess with the internal representation, and I managed to save macros, but when trying to open the Settings Editor again I was greeted with:
This works for
PyDMEmbeddedDisplay
though.The main difference I see here is that
PyDMEmbeddedDisplay
stores the macros as a dictionary encoded as simple JSON string, wherePyDMRelatedDisplayButton
stores them as a list of strings. When restoring the macros, there's no problem with the simple string, but the code chokes on the list of strings.Now, I'm not sure why the difference in storage choices, because there seems to be no good reason for
PyDMRelatedDisplayButton
to keep a list where a simple string would do, but you might have some insight that is escaping me :-)Steps to Reproduce
PyDMRelatedDisplayButton
Possible Solution
Change the storage choice for
PyDMRelatedDisplayButton
? It seems like using a simple string works fine forPyDMEmbeddedDisplay
My Platform
Happened on Linux, Python 3.9, latest stable PyDM (1.18.2)
The text was updated successfully, but these errors were encountered: