Maps as properties in Python plugin?

When writing a plugin in Python, one can add a list as property as following:

from System import Double
from System.Collections.Generic import List

prop = self.AddProperty(“Frequency”, , List[Double])
prop.AddAttribute(OpenTap.DisplayAttribute, “Frequency”, “Marker frequencies”, “Conditions”, 200)
prop.AddAttribute(OpenTap.UnitAttribute, “Hz”)

Can one do the same for dictionaries?


Hi Bram,

You would instantiate and create Dictionaries in Python SDK as under.

from System.Collections.Generic import List, Dictionary

    prop = self.AddProperty("MyDict", Dictionary[String, String](), Dictionary[String, String])
    prop.AddAttribute(BrowsableAttribute, False)
    self.MyDict["Hello"] = "World"

However, there is no direct GUI mapping for Dictionaries, so you’d have to set the Browsable attribute to False. You can operate on dictionaries the same way you work with native Python Dictionaries.
And if you’re going to be working with Dictionaries simply for storing data, you might as well directly use a native python Dictionary than instantiate a C# one.

MyDict = {'Hello' : 'World'}

Do you need a way to create and display a key-value pair on the GUI?