pycrate
pycrate copied to clipboard
Question: Reasonable approach to constructing an editor
I have written an editor using PyCrate and PySimpleGUI that works well for editing existing fields in an object. It uses get_val_paths() to go through a message and construct a PySimpleGUI TreeData. This works well, and didn't take too long to implement.
However, it only allows changing fields that already exist. I'd like to extend this to allow changing a Choice, generating some minimal/default value for that choice, and then allowing the user to modify the newly created sub-fields.
Any suggestions on how to do this? My first thought is that I can borrow some of the get_proto code, but that seems a fair amount of work.
I've attached a screenshot showing the editor I have working now.
When you set a value for a constructed type (CHOICE, SEQUENCE, SET) from scratch, you need to know all exact sub-components values. When working with such a graphical editor, it should propose a default values for all sub-components, that can be then edited further.
To initialize a value for a constructed type, you would need to go through all mandatory sub-components, assigning one default value in accordance with any existing constraint (value, size, content...) for each. What I would do myself is creating a common method to all ASN.1 types (e.g. set_default_val()
): for classes defined in asnobj_basic.py, asnobj_str.py, asnobj_construct.py and eventually asnobj_ext.py. In this way, calling such a method for a constructed object would just call it recursively to all its components.
This is still quite a lot of work, as defining default values could be cumbersome for some ASN.1 objects and constraints.
Sorry, I am coming back to this too. Did you implement something ? Feel free to open a PR. Otherwise we can just close the issue