8000 update config to dict · Issue #199 · compas-dev/compas_viewer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
update config to dict  #199
Open
Open
@PingHsunTsai

Description

@PingHsunTsai

Feature Request

suggest to update list config to dict config, to enable better access to the item.

Details

Origin

 items: list[dict] = field(
        default_factory=lambda: [
            {
                "type": "Sceneform",
                "columns": [
                    {"title": "Name", "type": "label", "text": lambda obj: obj.name},
                    {"title": "Show", "type": "checkbox", "checked": lambda obj: obj.show, "action": lambda obj, checked: setattr(obj, "show", checked)},
                ],
            },
            {
                "type": "ObjectSetting",
                "items": [
                    {"title": "Name", "items": [{"type": "text_edit", "action": lambda obj: obj.name}]},
                    {"title": "Point_Color", "items": [{"type": "color_dialog", "attr": "pointcolor"}]},
                    {"title": "Line_Color", "items": [{"type": "color_dialog", "attr": "linecolor"}]},
                    {"title": "Face_Color", "items": [{"type": "color_dialog", "attr": "facecolor"}]},
                    {"title": "Line_Width", "items": [{"type": "double_edit", "action": lambda obj: obj.linewidth, "min_val": 0.0, "max_val": 10.0}]},
                    {"title": "Point_Size", "items": [{"type": "double_edit", "action": lambda obj: obj.pointsize, "min_val": 0.0, "max_val": 10.0}]},
                    {"title": "Opacity", "items": [{"type": "double_edit", "action": lambda obj: obj.opacity, "min_val": 0.0, "max_val": 1.0}]},
                ],
            },
        ]
    )

updated config

items: dict = field(
    default_factory=lambda: {
        "Sceneform": {
            "columns": [
                {"title": "Name", "type": "label", "text": lambda obj: obj.name},
                {"title": "Show", "type": "checkbox", "checked": lambda obj: obj.show, "action": lambda obj, checked: setattr(obj, "show", checked)},
            ],
        }
    }
)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0