{"id":18467288,"url":"https://github.com/paulschweizer/qt-json-view","last_synced_at":"2025-04-08T09:32:01.378Z","repository":{"id":83700802,"uuid":"150948522","full_name":"PaulSchweizer/qt-json-view","owner":"PaulSchweizer","description":"Extendable Qt widget to display and edit JSON-serializable data","archived":false,"fork":false,"pushed_at":"2023-09-12T08:51:18.000Z","size":40,"stargazers_count":30,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T09:48:46.260Z","etag":null,"topics":["json","json-data","mvc","pyqt","pyside","pyside2","python","qt"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PaulSchweizer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-30T08:37:05.000Z","updated_at":"2025-01-14T14:07:10.000Z","dependencies_parsed_at":"2024-11-06T09:20:36.347Z","dependency_job_id":"650f1cce-751f-4a51-9a34-61e4c0687782","html_url":"https://github.com/PaulSchweizer/qt-json-view","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulSchweizer%2Fqt-json-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulSchweizer%2Fqt-json-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulSchweizer%2Fqt-json-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulSchweizer%2Fqt-json-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PaulSchweizer","download_url":"https://codeload.github.com/PaulSchweizer/qt-json-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247814044,"owners_count":21000489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","json-data","mvc","pyqt","pyside","pyside2","python","qt"],"created_at":"2024-11-06T09:19:26.475Z","updated_at":"2025-04-08T09:32:01.369Z","avatar_url":"https://github.com/PaulSchweizer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Qt JSON View\n\nThis widget allows to display and edit JSON-serializable data in a Qt view. The system is easily extensible with custom types.\n\nAn example to get you started is [here](example.py).\n\n![Qt JSON View](qt-json-view.png)\n\n## Overview\n\nA provided JSON-serializable dict or list is [converted](qt_json_view/model.py#L18) to a [JsonModel](qt_json_view/model.py#L6) derived from QStandardItemModel.\nDuring conversion, each entry in the source data is mapped to a [DataType](qt_json_view/datatypes.py#L11).\nThe [DataType](qt_json_view/datatypes.py#L11) defines how the entry is added to the [JsonModel](qt_json_view/model.py#L6), how it is serialized. The [JsonDelegate](qt_json_view/delegate.py#L6) draws on the optional [DataType](qt_json_view/datatypes.py#L11) implementations to display the item. The [DataType](qt_json_view/datatypes.py#L11) can also define custom right-click [QActions](qt_json_view/datatypes.py#L24) for the item.\nThe [JsonModel](qt_json_view/model.py#L6) can then be [serialized](qt_json_view/model.py#L29) back into a dictionary after editing.\n\n## DataTypes\n\nA number of data types are already implemented, but it is easy to implement and inject your own on the fly, please see section below.\n\n**Standard JSON Types:**\n\n* [NoneType](qt_json_view/datatypes.py#L85): None\n* [BoolType](qt_json_view/datatypes.py#L108): bool\n* [IntType](qt_json_view/datatypes.py#L115): int\n* [FloatType](qt_json_view/datatypes.py#L122): float\n* [StrType](qt_json_view/datatypes.py#L129): str and unicode\n* [ListType](qt_json_view/datatypes.py#L156): list\n* [DictType](qt_json_view/datatypes.py#L194): dict\n\n**Custom Types:**\n\n* [UrlType](qt_json_view/datatypes.py#L344): Detects urls and provides an \"Explore ...\" action opening the web browser.\n* [FilepathType](qt_json_view/datatypes.py#L362): Detects file paths and provides an \"Explore ...\" action opening the file browser\n* [RangeType](qt_json_view/datatypes.py#L235): A range is displayed in one row and has to be a dict in the form of, both floats and ints are allowed and displayed accordingly:\n```json\n{\n    \"start\": 0,\n    \"end\": 100,\n    \"step\": 2.5\n}\n```\n\n* [ChoicesType](qt_json_view/datatypes.py#L380): The user can choose from a range of choices. It is shown as a combobox. The data has to be a dict in the form:\n```json\n{\n    \"value\": \"A\",\n    \"choices\": [\"A\", \"B\", \"C\"]\n}\n```\n\n### Implement custom DataTypes\n\nSubclass the [DataType](qt_json_view/datatypes.py#L11) base class and implement what you need, at least the [matches](qt_json_view/datatypes.py#L16) method.\nThen inject an instance of your DataType into [datatypes.DATA_TYPES](qt_json_view/datatypes.py#L433) so it is found when the model is initialized.\nMake sure to inject it at the right position in the list [datatypes.DATA_TYPES](qt_json_view/datatypes.py#L433) list since the model uses the first match it finds.\n\n```python\nfrom qt_json_view import datatypes\n\nclass TestType(object):\n\n    def matches(self, data):\n        if data == \"TEST\":\n            return True\n        return False\n\nidx = [i for i in datatypes.DATA_TYPES if isinstance(i, datatypes.StrType)][0]\ndatatypes.DATA_TYPES.insert(idx, TestType())\n```\n\n## View\n\nThe [JsonView](qt_json_view/view.py) is a QTreeView with the delegate.JsonDelegate.\n\n## Model\n\nThe [JsonModel](qt_json_view/model.py) is a QStandardItemModel. It can be initialized from a JSON-serializable object and serialized to a JSON-serializable object.\n\n## Filtering\n\nThe [JsonSortFilterProxyModel](qt_json_view/model.py#L41) is a QSortFilterProxyModel extended to filter through the entire tree.\n\n## Delegate\n\nThe [JsonDelegate](qt_json_view/delegate.py) draws on the DataTypes of the items to determine how they are drawn. The [DataType](qt_json_view/datatypes.py#L11) uses the paint, createEditor and setModelData methods if they are available on the DataType.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulschweizer%2Fqt-json-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulschweizer%2Fqt-json-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulschweizer%2Fqt-json-view/lists"}