Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Question: Reasonable approach to constructing an editor #104

Open
andyvan-trabus opened this issue Sep 9, 2020 · 2 comments
Open

Question: Reasonable approach to constructing an editor #104

andyvan-trabus opened this issue Sep 9, 2020 · 2 comments
Assignees
Labels

Comments

@andyvan-trabus
Copy link

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.

Screenshot from 2020-09-08 17-27-11

@p1-bmu
Copy link
Contributor

p1-bmu commented Sep 9, 2020

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.

@p1-bmu
Copy link
Contributor

p1-bmu commented Oct 21, 2021

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

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

No branches or pull requests

2 participants