Support Python Dictionaries and Python Lists as Custom Properties of Components
closed
n
nick@perfectabstractions.com
Custom properties can be created on components in Ignition, but the types of these properties are limited to some standard Java types.
I think it would be really helpful if Python dictionary and Python list types could be used for custom properties.
Python dictionaries and lists are so extremely useful and convenient that having them as custom properties could significantly improve the ease and flexibility of Python scripting in Ignition
P
Paul Griffith
closed
At this point in Vision's development, I can confidently say we won't implement a significant change to Vision's property model like this.
L
Lynn.Martineau
I currently put JSON strings into a tag and use jsonGet expressions in the bindings on multiple components. It works quite well where I call external APIs that return JSON documents.
P
Phil Turmel
A PyObject property type would be a useful addition. However, it would have to be implemented such that saving anything unserializable (itself or nested) would drop the entire object. Python programmers would be tempted to stick their own classes into such a property, or in a collection, and that will blow up. (Been there, done that, with programmatically created "Object" custom properties.)
A workaround in the meantime is to leverage Java Swing's getClientProperty() & putClientProperty() methods, present on all Ignition components.
l
lionel MAZEYRAT
A Dictionnary datatype for tag's properties would be perfect to store additionnal information relative to a tag.
With a custom prop binding to this new kinf od tag prop !
n
nick@perfectabstractions.com
I agree with Carl's concerns. I think it would likely trip up and make programming in Ignition more complicated for new and less technical users of Ignition. And it would be something useful and nice for more technically advanced users. Perhaps there is a good balance somewhere.
Carl Gould
Well, I am a bit concerned about how this kind of datatype would play into the rest of the system. I can see the utility of this for passing data between windows. However, some concerns:
- They wouldn't work with binding. This isn't that big a deal, I guess.
- This is the big one. Python structures are mutable. This means that the value of the object could change, and you wouldn't know about it. No propertyChange event, nothing. I think this is a big problem.
I think a better solution might be to support a JSON datatype in some way...
J
Jayce Oxton
Carl Gould: I like this! Anything that could be done to support JSON would make things easier.
Z
Zack Scriven
I've done this by sending a JSON String.
n
nick@perfectabstractions.com
Also, Python dictionaries and lists have an easier syntax (than datasets) for accessing and setting values and many well documented methods for manipulating data. This greatly reduces the amount of code that is required to manipulate data making programs easier to read, write and understand.
n
nick@perfectabstractions.com
Why not just use a dataset? Because Python dictionaries are more flexible and easier to use. Because Python dictionaries and lists can be used to create nested data structures that makes the problem at hand easier to understand and solve. Because Python dictionaries require less code to implement solutions. Datasets are fine and good in many cases and should be used. But there are many more complex cases where Python dictionaries and lists are a better tool.
M
Mark French
Why not just use a dataset?
Load More
→