compas-dev / compas_view2

Standalone viewer for COMPAS
https://compas.dev/compas_view2/
MIT License
7 stars 9 forks source link

add value classes #159

Closed Licini closed 2 years ago

Licini commented 2 years ago

Started to add value classes that strong types everything. For example IntValue class would also check for data type, min and max etc. @brgcode Could you take look at this example scripts/v120_tree_editable.py And let me know if this is on the right direction?

data = [
    {"column1": "a", "column2": IntValue(1), "on_item_edited": on_item_edited, "some_binded_obj": {}},
    {"column1": "b", "column2": IntValue(2, min=0, max=10), "on_item_edited": on_item_edited},
    {"column1": "c", "column2": IntValue(3, options=[0, 1, 2, 3]), "on_item_edited": on_item_edited},
]
Licini commented 2 years ago

Added rest of classes, with a settings class on top of them, which can be used as a dict but strong typed: scripts/v120_settings.py

settings = Settings({
    "a": IntValue(1),
    "a2": IntValue(1, min=0, max=10),
    "a3": IntValue(1, options=[0, 1, 2, 3]),
    "b": FloatValue(0.005),
    "c": StrValue("some texts"),
    "d": ListValue([1, 2, 3], int),
    "e": DictValue({"a": 1}, int),
    "f": BoolValue(True),
})